Site | Changelog | Github | NPM | Docs
Downloading from NPM
$ npm i emrioutils --save
Then, in JavaScript:
const u = require('emrioutils')
or in Typescript/ES6
import u from 'emrioutils'
or
import u = require('emrioutils')
arr2obj
arr2objmap
binarySearch
binarySearchIndex
filterObj
hop
iterkv
makeShallowCopy
mapKey
mergekv
pourkv
rand
randstring
randUniqueList
resolveObjectProperty
rmfast
split
This project is intended for a personal use only. Future versions may include breaking changes if they fit my needs. Nonetheless feel free to use or fork the project.
Feel free to post some suggestions and/or questions in the Issues Page
Nested array type - array of array of array of ...
Retrieve the type of an array
T or null
T or null or undefined
T or undefined, equivalent to T?
Decimal base
Hexadecimal base
Binary base
Lowercase latin alphabet
Latin alphabet
Alphanumeric base without any homoglyphs
Alphanumeric alphabet
Cananocial Base64
URI-safe Base64
Octal base
Sizes for storage and bandwidth measurement in English and French
Maps array elements to an object Mapper function returns the key value
Maps array elements to an object Mapper function returns the key value and the value object
Gives the mean value of a list of numbers
Tests if given value is present is a sorted array
Returns the index of an element in a sorted array Returns -1 if element does not exist in array
Optionally takes a comparator function, more or less required if T is not string or number. This comparator should test if first argument is strictly greater than the second argument.
Capitalize the first character of a string
Creates a function that transforms a vector from source1 to source2 into another vector from dest1 to dest2 in a linear fashion
Creates a function that transforms a vector from source1 to source2 into another vector from dest1 to dest2 in a linear fashion
N-dimensional version of createLinearTransform
N-dimensional version of createLinearTransform
Get the day in a date (from 1 to 31*)
Get the day in a date (from '01' to '31'*)
Returns a custom string that represent the given date
Returns a custom string that represent the given date
Returns a custom string that represent the given date
Creates or retrieves a custom debugger class instance
TS implementation of Python's built-in enumerate function
Tests if two numbers are equal within an error margin
Tests if a file exists
Takes a record and creates a new record by filtering its keys
Returns the best size for a given raw size value
Array.flat
Get a string representing the size best
Returns a custom string that represent the given date
Returns a custom string that represent the given date
Shortcut for Object.prototype.hasOwnProperty.call
Get the hour in a date (from 0 to 23)
Get the hour in a date (from '00' to '23')
Returns the time between now and an hrtime record with nanosecond precision and casted to millisecond
Identity function Handy shortcut for (x: T): T => T in Typescript
Returns the elements that are present in both arrays
Tests if a file is a directory
Iterate through key/value pairs of an object
Returns the last element of an array. Optionally accepts an offset
Takes a list of records and merges them into another new record Collision are handled with the provided function
Get the minute in a date (from 0 to 59)
Get the minute in a date (from '00' to '59')
Get the month in a date (from 1 to 12)
Get the month in a date (from '01' to '12')
Intersection of sets
Creates an array of n items with a custom filler Shortcut for new Array(n).fill(undefined).map(fillerFunction)
Split an array's elements
Takes a list of records and pours their key-value pairs into another provided record. Takes a function for collision resolution when two objects have the same key
Returns a random element from a set This function is not cryptographically secure
Create a list of random values grabbed from a random function All values are unique
Draws values from the random function until any of desired array length or maximum withdraws amount is reached
For random functions that take parameters, please bind first
Returns a float number between two values This function is not cryptographically secure
Returns a string composed of characters in a provided alphabet Can return fixed length strings or random lengthed strings This function is not cryptographically secure
TS implementation of Python's built-in range function
In given text, replaces '{foo}' by the value of the property foo of the translation object. By default only replaces first occurence
resolveObjectProperty - Returns the reference of an object sub property Also creates sub properties if they do not exist
User should make sure paths exist or could exist on the object, else the function would throw somewhere.
Removes an element of an array at a given index in constant time Order of elements is not conserved Does not require array to be sorted
Rounds numbers with digits
Get the second in a date (from 0 to 59)
Get the second in a date (from '00' to '59')
Resolves a promise after a given period of time
Array.splice but for String
Split function which returns the end of the string as an element of the array if limit
is set
Swap two elements in an array
Union of sets
Removes all duplicates elements in an array
Removes all files in a directory May do so recursively May also remove sub directories
Get the year in a date
Get the year in a date (from '0000' to '9999') Only works correctly with dates from year 0 to year 9999
Returns a custom string that represent the given date
Returns a custom string that represent the given date
Returns a custom string that represent the given date
TS implementation of Python's built-in zip function
Generated using TypeDoc
Types that can be used as keys in a Record