Members
-
<constant> __
-
Placeholder argument for curried functions.
- Source:
- See:
Methods
-
add(a, b)
-
A curried version of the
+operator.Parameters:
Name Type Description aany bany - Source:
Returns:
- Type
- any
-
adjust(index, transformFn, list)
-
Returns a new array with the element at the provided index
updated by the transformation function.Parameters:
Name Type Description indexnumber transformFnfunction listArray.<any> - Source:
Returns:
- Type
- Array.<any>
-
all(condFn, list)
-
Checks if all elements of a list pass a condition.
Parameters:
Name Type Description condFnfunction listArray.<any> - Source:
Returns:
- Type
- boolean
-
allPass(functions, args)
-
Checks if all functions pass (return a truthy value).
The list of arguments will be applied to each function in turn (func(...args)).Parameters:
Name Type Description functionsArray.<function()> argsArray.<any> - Source:
- See:
Returns:
- Type
- boolean
-
always(arg)
-
Creates a nullary function that always returns the original argument.
Parameters:
Name Type Description argany - Source:
Returns:
- Type
- any
-
and(a, b)
-
A curried wrapper around the
&&operator.Parameters:
Name Type Description aany bany - Source:
Returns:
- Type
- any
-
any(condFn, list)
-
Checks if any of the elements in the list pass a condition.
Parameters:
Name Type Description condFnfunction listArray.<any> - Source:
Returns:
- Type
- boolean
-
anyPass(funcs, args)
-
Checks if any of the functions pass (return a truthy value).
The list of arguments will be applied to each function in turn (func(...args)).Parameters:
Name Type Description funcsArray.<function()> argsArray.<any> - Source:
- See:
Returns:
- Type
- boolean
-
ap(applyF, applyX)
-
Applies a list of functions to a list of values.
If functions are provided for both arguments, returns a function that's equivalent to f(x, g(x)).
Defers to theapmethod ofapplyF, if present.Parameters:
Name Type Description applyFapplicative | function | Array.<function()> applyXarray | function - Source:
Returns:
- Type
- any
-
append(value, list)
-
Appends a new element at the end of a list.
Parameters:
Name Type Description valueany listArray.<any> - Source:
Returns:
- Type
- Array.<any>
-
apply(func, args)
-
Applies a list of arguments to a function.
Thethisvariable will be set to undefined for that function execution.Parameters:
Name Type Description funcfunction argsArray.<any> - Source:
Returns:
- Type
- any
-
applyTo(x, fn)
-
Takes a value and a function and applies the function to the value.
With curry2ing, this allows for the creation of a function that always supplies the same value for different operations.Parameters:
Name Type Description xany fnfunction - Source:
Returns:
- Type
- any
-
arity(n, fn)
-
Create a new function with the specified arity between 0 and 10.
Parameters:
Name Type Description nnumber fnfunction - Source:
Returns:
- Type
- function
-
ascend(fn)
-
Creates an ascending comparator function to be used with the sort function.
Thefnargument must be a unary function that returns a value
that can be compared using the>and<operators,
this value will be used for the comparison.Parameters:
Name Type Description fnfunction - Source:
- See:
Returns:
- Type
- function
-
assoc(propName, value, object)
-
Creates a shallow copy of the object
and sets the value atpropName.Parameters:
Name Type Description propNamestring valueany objectobject - Source:
- See:
Returns:
- Type
- object
-
assocPath(path, value, object)
-
Creates a shallow copy of the object and sets
the value at the specified path.
The path can be specified as a dot-separated string
or a list of strings.Parameters:
Name Type Description pathstring | Array.<string> valueany objectobject - Source:
- See:
Returns:
- Type
- object
-
both(f1, f2, args)
-
Checks if both functions return a truthy value.
The arguments are applied to each function in turn (func(...args)).Parameters:
Name Type Description f1function f2function argsArray.<any> - Source:
- See:
Returns:
- Type
- boolean
-
chain(fn, list)
-
Maps a function over a list and concatenates the results.
Dispatches to thechainmethod of the second argument, if one exists.Parameters:
Name Type Description fnfunction listArray.<any> - Source:
Returns:
- Type
- Array.<any>
-
chunk(size, list)
-
Splits a list into a groups of smaller lists with the provided size.
chunk(2, [1, 2, 3, 4, 5, 6, 7]); // returns: // [[1, 2], [3, 4], [5, 6], [7]]
Parameters:
Name Type Description sizenumber listArray.<any> - Source:
Returns:
- Type
- Array.<any>
-
clamp(min, max, value)
-
Clamps a number to fit in a range.
Parameters:
Name Type Description minnumber maxnumber valuenumber - Source:
Returns:
- Type
- number
-
complement(func)
-
Creates a complementing funciton.
The new function will return true when the original function would have returned a falsy value
and false - when the original function would have returned a truthy value.Parameters:
Name Type Description funcfunciton - Source:
Returns:
- Type
- function
-
compose(funcs)
-
Takes a variable list of functions and returns a new function
that is a composition of all the functions that were passed.
The functions are called right-to-left.
The right-most function may have any arity, while the rest must be unary.
An example with three functions (f, g, h) => (...args) => h(g(f(...args)))Parameters:
Name Type Argument Description funcsfunction <repeatable>
- Source:
Returns:
- Type
- function
-
concat(left, right)
-
Concatenates 2 strings or 2 arrays.
Parameters:
Name Type Description leftstring | array rightstring | array - Source:
Returns:
- Type
- string | array
-
cond(pairs, arg)
-
Works a bit like the
switchstructure.
Contains pairs condition and transform functions.
The first condition function that returns a truthy value will cause its paired transform function to be called.
Both the condition and transform functions are passed theargparam.
Thepairsargument's format should look like this:[ [x => x > 5, x => x + 5], [x => x < 5, x => x - 5], [() => true, x => x], ]
If you have the last pair's condition function always return true,
it will work like thedefaultcase in aswitchstatement.
If you don't have a default case and none of the condition functions pass,
then the funciton will returnundefined.Parameters:
Name Type Description pairsArray.<any> argany - Source:
Returns:
- Type
- any
-
construct(classFn)
-
Creates a curried version of a constructor function.
The resulting function does not need the use of thenewkeyword.
The constructor function can only take up to 10 arguments.Parameters:
Name Type Description classFnfunction - Source:
Returns:
- Type
- function
-
constructN(n, classFn)
-
Creates a curried constructor, like
construct,
but also takes the constructor's arity as its first argument.Parameters:
Name Type Description nnumber classFnfunction - Source:
- See:
Returns:
- Type
- function
-
converge(convergingFn, branchingFns)
-
Takes a list of functions and a converging function.
Returns a new function that takes a variable number of arguments,
which will be applied to each of the branching functions.
The results of the branching functions will be passed to the converging function.Parameters:
Name Type Description convergingFnfunction branchingFnsArray.<function()> - Source:
Returns:
- Type
- function
-
curry(func)
-
Curries the provided function.
A curried function does not need to have all of its arguments provided at once.
Iffis a ternary andg = curry(f), then the following is equivalent:g(1)(2)(3); g(1)(2, 3); g(1, 2)(3); g(1, 2, 3);
Additionaly, the F.__ symbol can be used as a placeholder argument,
when you want to partially apply arguments with gaps inbetween them.g(1, __, 3)(2); g(__, __, 3)(1, 2); g(__, __, 3)(__, 2)(1);
Parameters:
Name Type Description funcfunction - Source:
Returns:
- Type
- function
-
curry1(fn)
-
A simplified curry for single-argument functions.
Parameters:
Name Type Description fnfunction - Source:
Returns:
- Type
- function
-
curry2(fn)
-
A simplified curry for binary functions.
Parameters:
Name Type Description fnfunction - Source:
Returns:
- Type
- function
-
dec(num)
-
Decrements a number.
Parameters:
Name Type Description numnumber - Source:
Returns:
- Type
- number
-
defaultTo(def, value)
-
If
valueis nil, then the default value will be returned,
otherwisevaluewill be returned.
CheckisNilto see which values are considered nil.Parameters:
Name Type Description defany valueany - Source:
- See:
Returns:
- Type
- any
-
descend(fn)
-
Creates a descending comparator function to be used with the sort function.
Thefnargument must be a unary function that returns a value
that can be compared using the>and<operators,
this value will be used for the comparison.Parameters:
Name Type Description fnfunction - Source:
- See:
Returns:
- Type
- function
-
difference(list1, list2)
-
Returns a unique list of elements from list1 that are not present in list2.
Comparison is done using theequalsfunction.Parameters:
Name Type Description list1Array.<any> list2Array.<any> - Source:
- See:
Returns:
- Type
- Array.<any>
-
differenceWith(equalsFn, list1, list2)
-
Returns a unique list of elements from list1 that are not present in list2.
Comparison is done using the binary function argument -equalsFn.Parameters:
Name Type Description equalsFnfunction list1Array.<any> list2Array.<any> - Source:
- See:
Returns:
- Type
- Array.<any>
-
dissoc(prop, object)
-
Creates a shallow copy of the object
with the element atpropremoved.Parameters:
Name Type Description propstring objectobject - Source:
- See:
Returns:
- Type
- object
-
dissocPath(path, object)
-
Creates a shallow copy of the object
with the element at the specified path removed.Parameters:
Name Type Description pathstring | Array.<string> objectobject - Source:
- See:
Returns:
- Type
- object
-
divide(divisor, divident)
-
A curried version of the
/operator.
Throws an error when trying to divide by zero.Parameters:
Name Type Description divisornumber dividentnumber - Source:
Returns:
- Type
- number
-
drop(index, list)
-
Creates a new array with the element at the specified index removed.
Parameters:
Name Type Description indexnumber listArray.<any> - Source:
Returns:
- Type
- Array.<any>
-
either(f1, f2, args)
-
Returns true if either one of the functions returns a truthy value with the provided arguments.
The arguments are applied to each function in turn(func(...args)).Parameters:
Name Type Description f1function f2function argsArray.<any> - Source:
Returns:
- Type
- boolean
-
equals(left, right)
-
Checks if the two arguments are equal
according to the strict equality comparison(===).
Defers toleft.equals(right)if such a method exists.Parameters:
Name Type Description leftany rightany - Source:
Returns:
- Type
- boolean
-
evolve(spec, object)
-
Creates a new object by going through the spec object/list recursively
and transforming the corresponding element in the target object.Parameters:
Name Type Description specobject | Array.<any> objectobject | Array.<any> - Source:
Returns:
- Type
- object | Array.<any>
-
F()
-
A utility function that always returns false regardless of its arguments.
- Source:
Returns:
- Type
- boolean
-
filter(func, list)
-
Filters the elements of an array, object or string
and returns a new array, object or string respectively.Parameters:
Name Type Description funcfunction listarray | string | object - Source:
Returns:
- Type
- array | string | object
-
find(condFn, list)
-
Returns the first element of a list that passes the condition function.
Parameters:
Name Type Description condFnfunction listArray.<any> | object - Source:
Returns:
- Type
- any
-
findIndex(condFn, list)
-
Returns the index of the first element that
passes the condition function or -1 if no element is found.Parameters:
Name Type Description condFnfunction listArray.<any> - Source:
Returns:
- Type
- number
-
findLast(condFn, list)
-
Returns the last element in the list that pases the condition function.
Parameters:
Name Type Description condFnfunction listArray.<any> - Source:
- See:
Returns:
- Type
- any
-
findLastIndex(condFn, list)
-
Finds the index of the last element that passes the condition function.
Retruns -1 if no element matches the condition.Parameters:
Name Type Description condFnfunction listArray.<any> - Source:
- See:
Returns:
- Type
- number
-
flatten(list)
-
Returns a new list with all nested arrays flattened.
Parameters:
Name Type Description listArray.<any> - Source:
- See:
Returns:
- Type
- Array.<any>
-
flip(func)
-
Creates a new function that takes its arguments
in reverse order of the original function.Parameters:
Name Type Description funcfunction - Source:
-
forEach(fn, list)
-
Runs a function for each element of the list, object or string.
Parameters:
Name Type Description fnfunction listArray.<any> | object | string - Source:
Returns:
- Type
- undefined
-
groupBy(groupFn, list)
-
Groups the elements of a list into an object
where the group of each element is determined by the grouping/key function.
The resulting object has the following format:{ "group1": [el, el2, el3], // elements for which `groupFn` returned `group1` "group2": [el4, el5], // elements for which `groupFn` returned `group2` // ... }Parameters:
Name Type Description groupFnfunction listArray.<any> - Source:
Returns:
- Type
- object
-
gt(right, left)
-
A curried wrapper around the
>operator.Parameters:
Name Type Description rightany leftany - Source:
Returns:
- Type
- boolean
-
gte(right, left)
-
A curried wrapper around the
>=operator.Parameters:
Name Type Description rightany leftany - Source:
Returns:
- Type
- boolean
-
has(prop, object)
-
Checks an object contains a prop.
Parameters:
Name Type Description propstring objectobject - Source:
Returns:
- Type
- boolean
-
hasPath(path, object)
-
Checks if a prop at at the given path exists.
The path can be given as a dot-separated string or a list of strings.Parameters:
Name Type Description pathstring | Array.<string> objectobject - Source:
Returns:
- Type
- boolean
-
head(list)
-
Returns the first element of a list or string.
Parameters:
Name Type Description listArray.<any> | string - Source:
Returns:
- Type
- any | string
-
identity(a)
-
The identity function just returns its first argument.
Parameters:
Name Type Description aany - Source:
Returns:
- Type
- any
-
inc(number)
-
Increments a number.
Parameters:
Name Type Description numbernumber - Source:
Returns:
- Type
- number
-
includes(element, fromIndex, list)
-
Checks if the list includes
element, starting fromfromIndex.
Defers to Array.prototype.includesParameters:
Name Type Description elementany fromIndexnumber listArray.<any> - Source:
Returns:
- Type
- boolean
-
indexOf(search, fromIndex, str)
-
Finds the index of the first match, or -1 if there's no match.
Parameters:
Name Type Description searchstring fromIndexinteger strstring - Source:
Returns:
- Type
- number
-
inRange(min, max, value)
-
Checks if a number is within range.
The lower boundary is inclusive and upper boundary is exclusive.Parameters:
Name Type Description minnumber maxnumber valuenumber - Source:
Returns:
- Type
- boolean
-
insert(index, value, list)
-
Inserts an element at the specified index, pushing the following elements back.
Parameters:
Name Type Description indexnumber valueany listArray.<any> - Source:
-
intersection(list1, list2)
-
Finds the intersection of two lists.
Uses theequalsfunction for comparison.Parameters:
Name Type Description list1Array.<any> list2Array.<any> - Source:
- See:
Returns:
- Type
- Array.<any>
-
intersectionWith(equalsFn, list1, list2)
-
Finds the intersection of two lists.
Uniqueness is determined by theequalsFn,
which takes an element from each list
and must return true if the two elements are considered equal.Parameters:
Name Type Description equalsFnfunction list1Array.<any> list2Array.<any> - Source:
- See:
Returns:
- Type
- Array.<any>
-
isEmpty(arg)
-
Checks if the value is empty.
Empty values are[],{}and''.Parameters:
Name Type Description argany - Source:
Returns:
- Type
- boolean
-
isNil(arg)
-
Checks if a value is nil.
A value is considered nil if it'snull,undefinedorNaN.Parameters:
Name Type Description argany - Source:
Returns:
- Type
- boolean
-
join(glue, list)
-
Joins the elements of a list into a string
with the "glue" string inbetween each element.
Defers to Array.prototype.joinParameters:
Name Type Description glue* list* - Source:
-
keys(obj)
-
Returns all own enumerable property names and symbols.
Parameters:
Name Type Description objobject - Source:
Returns:
- Type
- Array.<any>
-
keyWith(keyFn, list)
-
Creates an object whose keys are determined by
keyFn.
Each element of the list will be assigned in the object based on the key generated.
If the key function returns the same values for 2 elements from the list,
the one that's later in the list will overwrite the earlier one.
This function is useful if you have an array of objects that you want to convert to an object.Parameters:
Name Type Description keyFnfunction listArray.<any> - Source:
Returns:
- Type
- object
-
lens(getter, setter)
-
Takes a set of getter/setter functions
and wraps them in a lens object, that focuses on a specific part of a larger data object.
The lens should be used with theview,setandoverfunctions.
The lens should not be used on its own
as its internal implementation should be treated as a black box.The getter and setter functions should not modify the original data object.
The getter should be a unary function with the data as its only argument.
The setter function should be a binary function that receives the new value as its first argument
and the data object as its second argument.Parameters:
Name Type Description getterfunction setterfunction - Source:
- See:
Returns:
- Type
- object
-
lensIndex(index)
-
Creates a lens that will focus on a specific list index.
Parameters:
Name Type Description indexinteger - Source:
- See:
Returns:
- Type
- object
-
lensPath(path)
-
Creates a lens that will focus on a specific object path.
The path is specified the same way as in thepathfunction.Parameters:
Name Type Description pathstring | Array.<string> - Source:
- See:
Returns:
- Type
- object
-
lt(right, left)
-
A curried wrapper around the
<operator.Parameters:
Name Type Description rightany leftany - Source:
Returns:
- Type
- boolean
-
lte(right, left)
-
A curried wrapper around the
<=operator.Parameters:
Name Type Description rightany leftany - Source:
Returns:
- Type
- boolean
-
map(func, list)
-
Maps over a list, object or string and returns a new object of the corresponding type.
Each element of the collection is passed through the mapping function
and its return value is used for the new collection.
The mapping function receives(value, key, list),
wherelistis the full list, object or string.
Defers to Array.prototype.map for listsParameters:
Name Type Description funcfunction listArray.<any> | object | string - Source:
Returns:
- Type
- Array.<any> | object | string
-
mapIOInner(fn, ioInner)
-
Maps the inner value of a IO.
Parameters:
Name Type Description fnfunction ioInnerIO - Source:
Returns:
- Type
- IO
-
match(regex, str)
-
Matches the regular expression with the string and returns the match results.
Parameters:
Name Type Description regexRegExp strstring - Source:
Returns:
- Type
- Array.<string> | null
-
memoizeWith(keyGenerator, func)
-
Memoizes a function where the key generator function
decides which cached result should be returned.Parameters:
Name Type Description keyGeneratorfunction funcfunction - Source:
-
modulo(b, a)
-
A curried version of the modulo
%operator (a % b).Parameters:
Name Type Description bnumber anumber - Source:
Returns:
- Type
- number
-
multiply(a, b)
-
A curried version of the
*operator.Parameters:
Name Type Description anumber bnumber - Source:
Returns:
- Type
- number
-
not(arg)
-
A curried wrapper around the
!operator.Parameters:
Name Type Description argany - Source:
Returns:
- Type
- boolean
-
nth(n, list)
-
Returns the nth element of a list.
Parameters:
Name Type Description nnumber listArray.<any> - Source:
Returns:
- Type
- any
-
nthArg(index)
-
Takes an index and returns a function
that will return the argument with that index.
If the index is negative, then the argument will
be returned from the end of the argument list,
where -1 is the last argument.Parameters:
Name Type Description indexnumber - Source:
Returns:
- Type
- function
-
of(arg)
-
Wraps an argument in an array
Parameters:
Name Type Description argany - Source:
Returns:
- Type
- Array.<any>
-
or(a, b)
-
A curried wrapper around the
||operator.Parameters:
Name Type Description aany bany - Source:
Returns:
- Type
- any
-
over(lens, transformFn, data)
-
Runs the transform function over the part of the data that the lens is focusing on.
Parameters:
Name Type Description lensobject transformFnfunction dataany - Source:
- See:
Returns:
- Type
- any
-
path(path, object)
-
Returns the element at the specified path.
The path can be provided as a dot-separated string or as a list of strings.Parameters:
Name Type Description pathstring | Array.<string> objectobject - Source:
Returns:
- Type
- any
-
pathOr(defaultValue, path, object)
-
Returns the value at the given path or a default value if the path doesn't exist.
The path can be specified as a dot-separated string or a list of strings.Parameters:
Name Type Description defaultValueany pathstring | Array.<string> objectobject - Source:
Returns:
- Type
- object
-
pathSatisfies(condFn, path, object)
-
Checks if the value at the specified path passes the condition.
The path can be provided as a dot-separated string or a list of strings.Parameters:
Name Type Description condFnfunction pathstring | Array.<string> objectobject - Source:
Returns:
- Type
- boolean
-
pick(props, object)
-
Filters an object by only copying values that are in the
propslist.Parameters:
Name Type Description propsArray.<string> objectobject - Source:
Returns:
- Type
- object
-
pipe(funcs)
-
Takes a variable list of functions and returns a new function
that is a composition of all the functions that were passed.
The functions are called left-to-right.
The left-most function may have any arity, while the rest must be unary.
An example with three functions (f, g, h) => (...args) => f(g(h(...args)))Parameters:
Name Type Argument Description funcsfunction <repeatable>
- Source:
Returns:
- Type
- function
-
pluck(path, list)
-
Takes a list of objects and returns a new list with the values at the specified path plucked.
The path can be provided with a dot-separated string or a list of strings,
same as thepath*functions.Parameters:
Name Type Description pathstring | Array.<string> listArray.<object> - Source:
- See:
Returns:
- Type
- Array.<any>
-
prepend(value, list)
-
Prepends a value at the beginning of a list.
Parameters:
Name Type Description valueany listArray.<any> - Source:
Returns:
- Type
- Array.<any>
-
prop(propName, object)
-
Retruns the prop with the specified key.
Parameters:
Name Type Description propNamestring objectobject - Source:
Returns:
- Type
- any
-
propEq(propName, value, object)
-
Checks if the prop equals the specified value.
The comparisson is done using theequalsfunction.Parameters:
Name Type Description propNamestring valueany objectobject - Source:
Returns:
- Type
- boolean
-
propOr(defaultValue, propName, object)
-
Returns
object[prop]if it exists ordefaultValueotherwise.Parameters:
Name Type Description defaultValueany propNamestring objectobject - Source:
Returns:
- Type
- any
-
propSatisfies(conditionFn, propName, object)
-
Checks if the prop satisfies the condition function.
Parameters:
Name Type Description conditionFnfunction propNamestring objectobject - Source:
Returns:
- Type
- boolean
-
range(from, to)
-
Returns a list of numbers from the first argument(inclusive)
to the second argument(exclusive).Parameters:
Name Type Description fromnumber tonumber - Source:
Returns:
- Type
- Array.<number>
-
reduce(func, initialValue, list)
-
Reduces a list, object or string to a single value output value.
The reducer function receives the following arguments(accumulator, currentValue, key, list),
wherelistis the whole list, object or string.Parameters:
Name Type Description funcfunction initialValueany listArray.<any> | object | string - Source:
Returns:
- Type
- any
-
reduceWhile(condFn, reducer, initialValue, list)
-
Similar to
reduce, but it will terminate early if thecondFnreturns false.
The condition function receives the same arguments as the reducer.
See thereducefunction for details on the reducer arguments.Parameters:
Name Type Description condFnfunction reducerfunction initialValueany listArray.<any> | object | string - Source:
- See:
Returns:
- Type
- any
-
regexTest(regex, str)
-
Tests a string vs a regular expression.
Parameters:
Name Type Description regexRegExp strstring - Source:
Returns:
- Type
- boolean
-
replace(search, replacement, string)
-
Replaces
Parameters:
Name Type Description searchstring | RegExp replacementstring | function stringstring - Source:
Returns:
- Type
- string
-
reverse(listOrStr)
-
Returns a new list or string (depending on the argument)
with its order reversed.Parameters:
Name Type Description listOrStrArray.<any> | string - Source:
Returns:
- Type
- Array.<any> | string
-
set(lens, value, data)
-
Sets the value that the lens is focusing on by calling the lens setter.
Parameters:
Name Type Description lensobject valueany dataany - Source:
- See:
Returns:
- Type
- any
-
size(collection)
-
Returns the size of a list, object or string.
For lists and strings, it will just return thelengthproperty.
For objects - returns the sum of the counts of its own property names
and its own property symbols.Parameters:
Name Type Description collectionArray.<any> | object | string - Source:
Returns:
- Type
- number
-
slice(begin, end, list)
-
Slices an array from begin to end.
Defers to thelist.slicemethod.
See the documentation about Array.prototype.slice
and String.prototype.sliceParameters:
Name Type Description beginnumber endnumber listArray.<any> | string - Source:
Returns:
- Type
- Array.<any> | string
-
sort(predicate, list)
-
Returns a new list that's sorted according to the predicate.
Uses Array.prototype.sort
for the sorting, please refer to its documentation for the arguments that the predicate receives.
Note however that the sorting is done on a shallow copy of the original list.Parameters:
Name Type Description predicatefunction listArray.<any> - Source:
Returns:
- Type
- Array.<any>
-
splice(index, deleteCount, newElements, list)
-
Creates a shallow copy of the list and splices it,
deletingdeleteCountitems at the specified index (can be zero),
and insertingnewElementsin that place.
Notice thatnewElementscan also be an empty list.
UnlikeArray.prototype.splice, it receives its new elements as a list instead of
Rest parametersReference: Array.prototype.splice
Parameters:
Name Type Description indexnumber deleteCountnumber newElementsArray.<any> listArray.<any> - Source:
Returns:
- Type
- Array.<any>
-
split(delimiter, string)
-
Splits a string into a list of strings based on a delimiter.
Parameters:
Name Type Description delimiterstring stringstring - Source:
Returns:
- Type
- Array.<string>
-
subtract(b, a)
-
A curried version of the
-operator.Parameters:
Name Type Description bnumber anumber - Source:
Returns:
- Type
- number
-
T()
-
A utility function that always returns true regardless of its arguments.
- Source:
Returns:
- Type
- boolean
-
tail(list)
-
Returns all elements from a list or string, except the first one.
Parameters:
Name Type Description listArray.<any> | string - Source:
Returns:
- Type
- Array.<any> | string
-
take(n, list)
-
Takes the first
nelements of a list,
wherenis the number of elements to take.
The original list is left unchanged.Parameters:
Name Type Description nnumber listArray.<any> - Source:
Returns:
- Type
- Array.<any>
-
takeLast(numElements, list)
-
Similar to
take, but takes elements from the end of the list.Parameters:
Name Type Description numElementsnumber listArray.<any> - Source:
- See:
Returns:
- Type
- Array.<any>
-
tap(func, arg)
-
Runs a function on an argument and returns the argument.
Parameters:
Name Type Description funcfunction argany - Source:
Returns:
- Type
- any
-
thunkify(func)
-
Returns a new function that delays execution by returning a nullary function.
Parameters:
Name Type Description funcfunction - Source:
Returns:
- Type
- function
-
times(fn, n)
-
Executes
fnn times and returns its results as a list.
The predicate is passed the current iteration number as its only argument,
which ranges from 0 to n - 1.Parameters:
Name Type Description fnfunction ninteger - Source:
Returns:
- Type
- Array.<any>
-
toAsyncEither()
-
Executes a function that returns a promise and wraps its result in a Right.
If an exception is thrown it's caught and returned wrapped in a Left.Parameters:
Type Description function array - Source:
Returns:
- Type
- Promise.<Either>
-
toEither(fn, args)
-
Executes a function and wraps its result in a Right.
If an exception is thrown it's caught and returned wrapped in a Left.Parameters:
Name Type Description fnfunction argsarray - Source:
Returns:
-
toIOEither(fn, args)
-
Wraps a function in IO and Either.
Parameters:
Name Type Description fnfunction argsarray - Source:
Returns:
-
toLower(str)
-
Converts a string to lower case.
Parameters:
Name Type Description strstring - Source:
Returns:
- Type
- string
-
toUpper(str)
-
Converts a string to upper case.
Parameters:
Name Type Description strstring - Source:
-
trim(str)
-
Trims whitespace at the beginning and end of a string.
Parameters:
Name Type Description strstring - Source:
-
unapply(func)
-
Creates a variadic function from a unary function that accepts a list.
Parameters:
Name Type Description funcfunction - Source:
Returns:
- Type
- function
-
unfold(fn, seed)
-
Generates a list based on a seed and an iterator function.
The iterator function accepts a single argument - a seed.
The iterator needs to return eitherfalseto stop the generation or an array of 2 elements.
The first element in the array is the value that's going to be appended to the result,
while the second element is the seed for the next iteration.Parameters:
Name Type Description fnfunction seedany - Source:
Returns:
- Type
- Array.<any>
-
union(list1, list2)
-
Returns the union of the two lists.
Uses theequalsfunction to compare if two values are equal.Parameters:
Name Type Description list1Array.<any> list2Array.<any> - Source:
- See:
Returns:
- Type
- Array.<any>
-
unionWith(equalsFn, list1, list2)
-
Returns the union of two lists.
Comparisson is done with theequalsFn,
which is given two elements and must return true if they are considered equal.Parameters:
Name Type Description equalsFnfunction list1Array.<any> list2Array.<any> - Source:
- See:
Returns:
- Type
- Array.<any>
-
unique(list)
-
Returns a new list with duplicate values removed.
The comparison is done with theequalsfunction.Parameters:
Name Type Description listArray.<any> - Source:
- See:
Returns:
- Type
- Array.<any>
-
unless(conditionFn, elseFn, arg)
-
Returns the result of
elseFn(arg)only ifconditionFn(arg)returns a falsy value,
otherwise returns the argument unchanged.Parameters:
Name Type Description conditionFnfunction elseFnfunction argany - Source:
- See:
Returns:
- Type
- any
-
unnest(list)
-
Removes one level of list nesting.
Parameters:
Name Type Description listArray.<any> - Source:
- See:
Returns:
- Type
- Array.<any>
-
update(index, value, list)
-
Returns a new array with the value at the specified index updated.
Parameters:
Name Type Description indexinteger valueany listArray.<any> - Source:
-
values(obj)
-
Returns the values of all own enumerable property names and symbols.
Parameters:
Name Type Description objobject - Source:
Returns:
- Type
- Array.<any>
-
view(lens, data)
-
Returns the specific part of the data that the lens is focusing on.
Parameters:
Name Type Description lensobject dataany - Source:
- See:
Returns:
- Type
- any
-
when(conditionFn, thenFn, arg)
-
Returns the result of
thenFn(arg)only ifconditionFn(arg)returns a truthy value,
otherwise returns the argument unchanged.Parameters:
Name Type Description conditionFnfunction thenFnfunction argany - Source:
- See:
Returns:
- Type
- any
-
where(specObject, testObject)
-
Checks if all of the condition functions in the spec object pass.
Parameters:
Name Type Description specObjectobject testObjectobject - Source:
Returns:
- Type
- boolean
-
without(values, list)
-
Removes a list of values from the target list.
Equality comparisson is made with theequalsfunction.Parameters:
Name Type Description valuesArray.<any> listArray.<any> - Source:
- See:
Returns:
- Type
- Array.<any>
-
xor(a, b)
-
A curried wrapper around the
^operator.Parameters:
Name Type Description aany bany - Source:
-
zip(list1, list2)
-
Creates a new list with pairs of values from the 2 lists,
where each pair consists of the element with the same index from each array.
If one list has more elements than the other,
then the pairing will be done up to the lenght of the shorter array.
The resulting array has the following format:[ [list1el1, list2el1], [list1el2, list2el2], // ... ]
Parameters:
Name Type Description list1Array.<any> list2Array.<any> - Source:
-
zipObj(keys, values)
-
Similar to
zip, but the elements of the first list are used for keys
and the values of the second list are used as values for the resulting object.
The format of the resulting object is the following:{ [list1el1]: list2el1, [list1el2]: list2el2, // ... }Parameters:
Name Type Description keysArray.<any> valuesArray.<any> - Source:
- See:
Returns:
- Type
- object