Functions for working with functions, sequences and collections.
Alias for fn.apply(context, ...args).
apply(Math.sqrt, 25) // => 5Returns a partially applied version of fn.
let add = (a, b) => a + b;
let add10 = partial(add, 10);
add10(5); // => 15Returns a function that executes argument functions sequantially from left to right passing their return value as an argument to the next function.
let square = n => n * n;
let cube = compose(square, square);
cube(2); // => 16Returns a sequence of all but the first n elements of the sequence seq.
seq may be an array or a string and n must be an integer. The result is the same type of sequence as seq.
drop([1, 2, 3, 4], 2); // => [3, 4]
drop('foobar', 3); // => 'bar'Returns a sub-sequence of the successive elements of seq for which calling pred with that element returns non-nil.
pred must be a one-argument function and seq may be an array or a string. The result is the same type of sequence as seq.
dropWhile(isOdd, [1, 2, 3, 4]) // => [2, 3, 4]
dropWhile(isAlphabetic, 'foo123') // => '123'Returns a sequence of the first n elements of seq.
seq may be an array or a string and n must be an integer. The result is the same type of sequence as seq.
take([1, 2, 3, 4], 2); // => [1, 2]
take('foobar', 3); // => 'foo'Returns a sub-sequence of the successive elements of seq for which calling pred with that element returns non-nil.
pred must be a one-argument function and seq may be an array, or a string. The result is the same type of sequence as seq.
takeWhile(isOdd, [1, 2, 3, 4]) // => [1]
takeWhile(isAlphabetic, 'foo123') // => 'foo'Calls fn for each element in seq. If seq is an object, calls fn with key and value.
each([1, 2], print) // => 1 2Returns a list of all the elements in seq for which calling pred with that element returns false.
filter(isOdd, [1, 2, 3, 4]) // => [2, 4]
filter(isAlphabetic, 'foo123') // => '123'Returns a collection of all arguments concatenated together.
If args are objects, they are merged from right to left.
concat([1, 2], [3, 4]) // => [1, 2, 3, 4]
concat('foo', 'bar') // => 'foobar'
concat({foo: 2}, {bar: 2}, {foo: 1}) // => {foo: 1, bar: 2}Returns a negated version of a predicate function.
let isNotDigit = not(isDigit);
isDigit('1') // => true
isNotDigit('1') // => falseReturns true if char is a digit, false otherwise.
isDigit('1') // => true
isDigit('f') // => falseReturns true if char is alphabetic, false otherwise.
isAlphabetic('a') // => true
isAlphabetic('9') // => falseThe identity function. Returns the argument as is.
Returns an all uppercase version of the argument string. Alias for String.prototype.toUpperCase.
Returns an all lowercase version of the argument string. Alias for String.prototype.toLowerCase.
Returns the argument string without any heading or trailing whitespace. Alias for String.prototype.trim.
Alias for JSON.stringify.