Functions
Browse all available utility functions by category
after
The opposite of before; this method creates a function that invokes func once it's called n or more times.
Example:
const saves = ['profile', 'settings'];ary
Creates a function that invokes func, with up to n arguments, ignoring any additional arguments.
Example:
map(['6', '8', '10'], ary(parseInt, 1)); // [6, 8, 10]before
Creates a function that invokes func, with the this binding and arguments of the created function, while it's called less than n times.
Example:
jQuery(element).on('click', before(5, addContactToList));bind
Creates a function that invokes func with the this binding of thisArg and partials prepended to the arguments it receives.
Example:
const greet = function(greeting: string, punctuation: string) {bindKey
Creates a function that invokes the method at object[key] with partials prepended to the arguments it receives.
Example:
const object = {curry
Creates a function that accepts arguments of func and either invokes func returning its result, or returns a function that accepts the remaining arguments.
Example:
const abc = (a: string, b: string, c: string) => [a, b, c];curryRight
This method is like curry except that arguments are applied to func in the manner of partialRight instead of partial.
Example:
const abc = (a: string, b: string, c: string) => [a, b, c];debounce
Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked.
Example:
const debounced = debounce(() => console.log('hello'), 1000);defer
Defers invoking the func until the current call stack has cleared.
Example:
defer((text: string) => console.log(text), 'deferred'); // Logs 'deferred' after one millisecond.delay
Invokes func after wait milliseconds.
Example:
delay((text: string) => console.log(text), 1000, 'later'); // Logs 'later' after one second.flip
Creates a function that invokes func with arguments reversed.
Example:
const flipped = flip((...args: unknown[]) => args);memoize
Creates a function that memoizes the result of func.
Example:
const object = { 'a': 1, 'b': 2 };negate
Creates a function that negates the result of the predicate func.
Example:
const isEven = (n: number) => n % 2 === 0;once
Creates a function that is restricted to invoking func once.
Example:
const initialize = once(() => console.log('initialized'));overArgs
Creates a function that invokes func with its arguments transformed.
Example:
function doubled(n: number) {partial
Creates a function that invokes func with partials prepended to the arguments it receives.
Example:
function greet(greeting: string, name: string) {partialRight
This method is like partial except that partials are appended to the arguments it receives.
Example:
function greet(greeting: string, name: string) {rearg
Creates a function that invokes func with arguments arranged according to the specified indexes.
Example:
const rearged = rearg((a: string, b: string, c: string) => [a, b, c], [2, 0, 1]);rest
Creates a function that invokes func with the this binding of the created function and arguments from start and beyond provided as an array.
Example:
const say = rest((what: string, names: string[]) => what + ' ' + names.join(', '));spread
Creates a function that invokes func with the array of arguments provided to the created function.
Example:
const say = spread((who: string, what: string) => who + ' says ' + what);throttle
Creates a throttled function that only invokes func at most once per every wait milliseconds.
Example:
const throttled = throttle(() => console.log('hello'), 1000);unary
Creates a function that accepts up to one argument, ignoring any additional arguments.
Example:
map(['6', '8', '10'], unary(parseInt)); // [6, 8, 10]wrap
Creates a function that provides value to wrapper as its first argument.
Example:
const p = wrap(escape, (func: typeof escape, text: string) => '<p>' + func(text) + '</p>');