/** * Get the name of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/name) * @param x a function * @returns name */ declare function name(x: Function): string; /** * Get the number of parameters of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/length) * @param x a function * @returns |[p, q, ...]| | x(p, q, ...) */ declare function length(x: Function): number; /** * Bind this-object, and optional prefix arguments to a function. * [📘](https://github.com/nodef/extra-async-function/wiki/bind) * @param x a function * @param ths this object to bind * @param prefix prefix arguments * @returns (...args) => this.x(...prefix, ...args) */ declare function bind(x: Function, ths: any, ...prefix: any[]): Function; /** * Invoke a function with specified this-object, and arguments provided individually. * [📘](https://github.com/nodef/extra-async-function/wiki/call) * @param x a function * @param ths this object to invoke with * @param args arguments * @returns this.x(...args) */ declare function call(x: Function, ths?: any, ...args: any[]): any; /** * Invoke a function with specified this-object, and arguments provided as an array. * [📘](https://github.com/nodef/extra-async-function/wiki/apply) * @param x a function * @param ths this object to invoke with * @param args arguments array * @returns this.x(...args) */ declare function apply(x: Function, ths: any, args: any[]): any; /** * Check if value is an async function. * [📘](https://github.com/nodef/extra-function/wiki/isAsync) * @param v a value * @returns is async function? */ declare function isAsync(v: any): boolean; /** * Check if value is a generator function. * [📘](https://github.com/nodef/extra-async-function/wiki/isGenerator) * @param v a value * @returns is generator function? */ declare function isGenerator(v: any): v is GeneratorFunction; /** * Contextify a function by accepting the first parameter as this-object. * [📘](https://github.com/nodef/extra-async-function/wiki/contextify) * @param x a function * @returns (...args) => x(this, ...args) */ declare function contextify(x: Function): Function; /** * Decontextify a function by accepting this-object as the first argument. * [📘](https://github.com/nodef/extra-async-function/wiki/decontextify) * @param x a function * @returns (this, ...args) => this.x(...args) */ declare function decontextify(x: Function): Function; /** * Resolve arguments into a unique key. * [📘](https://github.com/nodef/extra-async-function/wiki/Resolver) * @param args arguments * @returns unique key */ type Resolver = (...args: any[]) => any; /** * Generate a parameter-reversed version of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/reverse) * @param x a function * @returns (p, q, ...) => x(..., q, p) */ declare function reverse(x: Function): Function; /** * Generate a (first) parameter-spreaded version of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/spread) * @param x a function * @returns (p, q, ...) => x([p, q, ...]) */ declare function spread(x: Function): Function; /** * Generate a (first) parameter-collapsed version of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/unspread) * @param x a function * @returns ([p, q, ...]) => x(p, q, ...) */ declare function unspread(x: Function): Function; /** * Attach prefix arguments to leftmost parameters of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/attach) * @param x a function * @param prefix prefix arguments * @returns (...args) => x(...prefix, ...args) */ declare function attach(x: Function, ...prefix: any[]): Function; /** * Attach suffix arguments to rightmost parameters of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/attachRight) * @param x a function * @param suffix suffix arguments * @returns (...args) => x(...args, ...suffix) */ declare function attachRight(x: Function, ...suffix: any[]): Function; /** * Generate curried version of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/curry) * @param x a function * @param n number of parameters [all] * @returns (p)(q)(...) => x(p, q, ...) */ declare function curry(x: Function, n?: number): Function; /** * Generate right-curried version of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/curryRight) * @param x a function * @param n number of parameters [all] * @returns (p)(q)(...) => x(..., q, p) */ declare function curryRight(x: Function, n?: number): Function; /** * Invocation control for time/rate-controlled functions. * [📘](https://github.com/nodef/extra-async-function/wiki/InvocationControl) */ interface InvocationControl { /** Disable invoking of target function. */ clear: () => void; /** Immediately invoke target function. */ flush: () => void; } /** * Generate deferred version of a function, that executes after the current stack has cleared. * [📘](https://github.com/nodef/extra-async-function/wiki/defer) * @param x a function * @returns (...args) => invocation control */ declare function defer(x: Function): Function; /** * Generate delayed version of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/delay) * @param x a function * @param t delay time (ms) * @returns (...args) => invocation control */ declare function delay(x: Function, t: number): Function; /** * Generate restricted-use version of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/restrict) * @param x a function * @param start usable from * @param end usable till (excluding) [-1 ⇒ end] * @returns (...args) => x(...args) from [start:end] calls */ declare function restrict(x: Function, start: number, end?: number): Function; /** * Restrict a function to be used only once. * [📘](https://github.com/nodef/extra-async-function/wiki/restrictOnce) * @param x a function * @returns (...args) => x(...args) from [0:1] calls */ declare function restrictOnce(x: Function): Function; /** * Restrict a function to be used only upto a certain number of calls. * [📘](https://github.com/nodef/extra-async-function/wiki/restrictBefore) * @param x a function * @param n number of calls upto which it is usable * @returns (...args) => x(...args) from [0:n] calls */ declare function restrictBefore(x: Function, n: number): Function; /** * Restrict a function to be used only after a certain number of calls. * [📘](https://github.com/nodef/extra-async-function/wiki/restrictAfter) * @param x a function * @param n number of calls after which it is usable * @returns (...args) => x(...args) from [n:end] calls */ declare function restrictAfter(x: Function, n: number): Function; /** * Generate debounced version of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/debounce) * @param x a function * @param t delay time (ms) * @param T max delay time [-1 ⇒ none] * @returns (...args) => invocation control */ declare function debounce(x: Function, t: number, T?: number): Function; /** * Generate leading-edge debounced version of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/debounceEarly) * @param x a function * @param t delay time (ms) * @param T max delay time [-1 ⇒ none] * @returns (...args) => invocation control */ declare function debounceEarly(x: Function, t: number, T?: number): Function; /** * Generate throttled version of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/throttle) * @param x a function * @param t wait time (ms) * @returns (...args) => invocation control */ declare function throttle(x: Function, t: number): Function; /** * Generate leading-edge throttled version of a function. * [📘](https://github.com/nodef/extra-async-function/wiki/throttleEarly) * @param x a function * @param t wait time (ms) * @returns (...args) => invocation control */ declare function throttleEarly(x: Function, t: number): Function; /** * Resolve all the arguments passed, as an array. * [📘](https://github.com/nodef/extra-async-function/wiki/ARGUMENTS) * @param args arguments * @returns [...args] */ declare function ARGUMENTS(...args: any[]): Promise; /** * Do nothing. * [📘](https://github.com/nodef/extra-async-function/wiki/NOOP) * @param args arguments (ignored) */ declare function NOOP(...args: any[]): Promise; /** * Return the same (first) value. * [📘](https://github.com/nodef/extra-async-function/wiki/IDENTITY) * @param v a value * @returns v */ declare function IDENTITY(v: T): Promise; /** * Compare two async values. * [📘](https://github.com/nodef/extra-async-function/wiki/COMPARE) * @param a an async value * @param b another async value * @returns ab: 1 */ declare function COMPARE(a: T | Promise, b: T | Promise): Promise; /** * Generate a result-negated version of an async function. * [📘](https://github.com/nodef/extra-async-function/wiki/negate) * @param x an async function * @returns (...args) => !x(...args) */ declare function negate(x: Function): Function; /** * Generate result-cached version of an async function. * [📘](https://github.com/nodef/extra-async-function/wiki/memoize) * @param x an async function * @param fr async resolver ((...args) => unique key) [IDENTITY] * @param cache result cache [Map()] */ declare function memoize(x: Function, fr?: Resolver, cache?: Map): Function; /** * Compose async functions together, in applicative order. * [📘](https://github.com/nodef/extra-async-function/wiki/compose) * @param xs async functions (f, g) * @returns (f o g), or f(g(x)) */ declare function compose(...xs: Function[]): Function; /** * Compose async functions together, such that result is piped forward. * [📘](https://github.com/nodef/extra-async-function/wiki/composeRight) * @param xs async functions (f, g) * @returns (f ▷ g), or g(f(x)) */ declare function composeRight(...xs: Function[]): Function; export { ARGUMENTS, COMPARE, IDENTITY, type InvocationControl, NOOP, type Resolver, restrictAfter as after, apply, length as arity, attach, attachRight, restrictBefore as before, bind, call, compose, composeRight, contextify, curry, curryRight, debounce, debounceEarly, decontextify, defer, delay, reverse as flip, isAsync as is, isGenerator, length, memoize, name, negate, restrictOnce as once, attach as partial, attachRight as partialRight, restrict, restrictAfter, restrictBefore, restrictOnce, reverse, spread, throttle, throttleEarly, unspread };