@esfx/fn Package

    Common utility functions.

    Installation

    npm i @esfx/fn
    

    Classes

    DefaultMemoizeCache

    The default implementation of a MemoizeCache<A, T>, as used by memoize(factory, options).

    Non-primitive keys have a lifetime scoped to both the life of the key (using a WeakMap) and the life of the cache. Results associated with a non-primitive key can be garbage collected if the key is garbage collected.

    Primitive keys have a lifetime scoped to the life of the cache, so results associated with a primitive key can only be garbage collected if the cache is garbage collected.

    Interfaces

    MemoizeCache<A, T>

    Describes the minimum implementation of a cache for memoize(factory, options).

    MemoizeCacheEntry<T>

    Describes the minimum implementation of a cache entry for a MemoizeCache<A, T>.

    MemoizeCacheFulfilledResult<T>

    Describes a cache result that has a value.

    MemoizeCacheRejectedResult

    Describes a cache result that has an exception.

    MemoizeOptions<A, T>

    Functions

    allocator()

    Returns a function that constructs an instance from a constructor provided as its first argument.

    const fn = allocator("Bob");
    class Person {
      constructor(name) { this.name = name; }
    }
    class Dog {
      constructor(owner) { this.owner = owner; }
    }
    fn(Person).name; // "Bob"
    fn(Dog).owner; // "Bob"
    
    Declaration
    export declare function allocator(): <R, A extends unknown[]>(ctor: new (...args: A) => R, ...args: A) => R;
    Returns
    <R, A extends unknown[]>(ctor: new (...args: A) => R, ...args: A) => R

    allocator(a0)

    Declaration
    export declare function allocator<A0>(a0: A0): <R, A extends unknown[]>(ctor: new (a0: A0, ...args: A) => R, ...args: A) => R;
    Type Parameters
    A0

    Parameters
    a0
    A0

    Returns
    <R, A extends unknown[]>(ctor: new (a0: A0, ...args: A) => R, ...args: A) => R

    allocator(a0, a1)

    Declaration
    export declare function allocator<A0, A1>(a0: A0, a1: A1): <R, A extends unknown[]>(ctor: new (a0: A0, a1: A1, ...args: A) => R, ...args: A) => R;
    Type Parameters
    A0

    A1

    Parameters
    a0
    A0

    a1
    A1

    Returns
    <R, A extends unknown[]>(ctor: new (a0: A0, a1: A1, ...args: A) => R, ...args: A) => R

    allocator(a0, a1, a2)

    Declaration
    export declare function allocator<A0, A1, A2>(a0: A0, a1: A1, a2: A2): <R, A extends unknown[]>(ctor: new (a0: A0, a1: A1, a2: A2, ...args: A) => R, ...args: A) => R;
    Type Parameters
    A0

    A1

    A2

    Parameters
    a0
    A0

    a1
    A1

    a2
    A2

    Returns
    <R, A extends unknown[]>(ctor: new (a0: A0, a1: A1, a2: A2, ...args: A) => R, ...args: A) => R

    allocator(a0, a1, a2, a3)

    Declaration
    export declare function allocator<A0, A1, A2, A3>(a0: A0, a1: A1, a2: A2, a3: A3): <R, A extends unknown[]>(ctor: new (a0: A0, a1: A1, a2: A2, a3: A3, ...args: A) => R, ...args: A) => R;
    Type Parameters
    A0

    A1

    A2

    A3

    Parameters
    a0
    A0

    a1
    A1

    a2
    A2

    a3
    A3

    Returns
    <R, A extends unknown[]>(ctor: new (a0: A0, a1: A1, a2: A2, a3: A3, ...args: A) => R, ...args: A) => R

    allocator(args)

    Declaration
    export declare function allocator<A extends unknown[]>(...args: A): <R>(ctor: new (...args: A) => R) => R;
    Type Parameters
    A

    Parameters
    args
    A

    Returns
    <R>(ctor: new (...args: A) => R) => R

    allocator(args)

    Declaration
    export declare function allocator<AX>(...args: AX[]): <R>(ctor: new (...args: AX[]) => R, ...args: AX[]) => R;
    Type Parameters
    AX

    Parameters
    args
    AX[]

    Returns
    <R>(ctor: new (...args: AX[]) => R, ...args: AX[]) => R

    always(value)

    Returns a function that returns the provided value.

    Declaration
    export declare function always<T>(value: T): () => T;
    Type Parameters
    T

    Parameters
    value
    T

    Returns
    () => T

    alwaysFail(error)

    Returns a function that always throws the provided error.

    Declaration
    export declare function alwaysFail(error: unknown): () => never;
    Parameters
    error
    unknown

    Returns
    () => never

    alwaysFalse()

    A function that always returns false.

    Declaration
    export declare function alwaysFalse(): false;
    Returns
    false

    alwaysTrue()

    A function that always returns true.

    Declaration
    export declare function alwaysTrue(): true;
    Returns
    true

    both(a, b)

    Returns a function that returns the result of calling its first argument if that result is "falsy", otherwise returning the result of calling its second argument. NOTE: This performs the same shortcutting as a logical AND (i.e. a() && b())

    Declaration
    export declare function both<T, U extends T, V extends T>(a: (t: T) => t is U, b: (t: T) => t is V): (t: T) => t is U & V;
    Type Parameters
    T

    U

    V

    Parameters
    a
    (t: T) => t is U

    b
    (t: T) => t is V

    Returns
    (t: T) => t is U & V

    both(a, b)

    Declaration
    export declare function both<A extends unknown[], R1, R2>(a: (...args: A) => R1, b: (...args: A) => R2): (...args: A) => R1 extends (null | undefined | false | 0 | 0n | '') ? R1 : R2 extends (null | undefined | false | 0 | 0n | '') ? R2 : R1 | R2;
    Type Parameters
    A

    R1

    R2

    Parameters
    a
    (...args: A) => R1

    b
    (...args: A) => R2

    Returns
    (...args: A) => R1 extends (null | undefined | false | 0 | 0n | '') ? R1 : R2 extends (null | undefined | false | 0 | 0n | '') ? R2 : R1 | R2

    caller()

    Returns a function that calls the function provided as its first argument.

    const fn = caller(1, 2);
    fn((a, b) => a + b); // 3
    
    Declaration
    export declare function caller(): <R, A extends unknown[]>(func: (...args: A) => R, ...args: A) => R;
    Returns
    <R, A extends unknown[]>(func: (...args: A) => R, ...args: A) => R

    caller(a0)

    Declaration
    export declare function caller<A0>(a0: A0): <R, A extends unknown[]>(func: (a0: A0, ...args: A) => R, ...args: A) => R;
    Type Parameters
    A0

    Parameters
    a0
    A0

    Returns
    <R, A extends unknown[]>(func: (a0: A0, ...args: A) => R, ...args: A) => R

    caller(a0, a1)

    Declaration
    export declare function caller<A0, A1>(a0: A0, a1: A1): <R, A extends unknown[]>(func: (a0: A0, a1: A1, ...args: A) => R, ...args: A) => R;
    Type Parameters
    A0

    A1

    Parameters
    a0
    A0

    a1
    A1

    Returns
    <R, A extends unknown[]>(func: (a0: A0, a1: A1, ...args: A) => R, ...args: A) => R

    caller(a0, a1, a2)

    Declaration
    export declare function caller<A0, A1, A2>(a0: A0, a1: A1, a2: A2): <R, A extends unknown[]>(func: (a0: A0, a1: A1, a2: A2, ...args: A) => R, ...args: A) => R;
    Type Parameters
    A0

    A1

    A2

    Parameters
    a0
    A0

    a1
    A1

    a2
    A2

    Returns
    <R, A extends unknown[]>(func: (a0: A0, a1: A1, a2: A2, ...args: A) => R, ...args: A) => R

    caller(a0, a1, a2, a3)

    Declaration
    export declare function caller<A0, A1, A2, A3>(a0: A0, a1: A1, a2: A2, a3: A3): <R, A extends unknown[]>(func: (a0: A0, a1: A1, a2: A2, a3: A3, ...args: A) => R, ...args: A) => R;
    Type Parameters
    A0

    A1

    A2

    A3

    Parameters
    a0
    A0

    a1
    A1

    a2
    A2

    a3
    A3

    Returns
    <R, A extends unknown[]>(func: (a0: A0, a1: A1, a2: A2, a3: A3, ...args: A) => R, ...args: A) => R

    caller(args)

    Declaration
    export declare function caller<A extends unknown[]>(...args: A): <R>(func: (...args: A) => R) => R;
    Type Parameters
    A

    Parameters
    args
    A

    Returns
    <R>(func: (...args: A) => R) => R

    caller(args)

    Declaration
    export declare function caller<AX>(...args: AX[]): <R>(func: (...args: AX[]) => R, ...args: AX[]) => R;
    Type Parameters
    AX

    Parameters
    args
    AX[]

    Returns
    <R>(func: (...args: AX[]) => R, ...args: AX[]) => R

    clamp(min, max)

    Clamps a value to a set range using the default Comparer.

    const fn = clamp(0, 10);
    fn(-1); // 0
    fn(15); // 10
    fn(7); // 7
    
    Declaration
    export declare function clamp<T>(min: T, max: T): (value: T) => T;
    Type Parameters
    T

    Parameters
    min
    T

    max
    T

    Returns
    (value: T) => T

    compare(a, b)

    Compares two values using the default Comparer.

    Declaration
    export declare function compare<T>(a: T, b: T): number;
    Type Parameters
    T

    Parameters
    a
    T

    b
    T

    Returns
    number

    complement(f)

    Returns a function that returns the complement of calling f.

    alwaysTrue(); // true
    complement(alwaysTrue)(); // false
    
    alwaysFalse(); // false
    complement(alwaysFalse)(); // true
    
    Declaration
    export declare function complement<A extends unknown[]>(f: (...args: A) => boolean): (...args: A) => boolean;
    Type Parameters
    A

    Parameters
    f
    (...args: A) => boolean

    Returns
    (...args: A) => boolean

    compose(fb, fa)

    Right-to-left composition of functions (i.e. compose(g, f) is x => g(f(x))).

    Declaration
    export declare function compose<A extends unknown[], B, C>(fb: (b: B) => C, fa: (...a: A) => B): (...a: A) => C;
    Type Parameters
    A

    B

    C

    Parameters
    fb
    (b: B) => C

    fa
    (...a: A) => B

    Returns
    (...a: A) => C

    compose(fc, fb, fa)

    Declaration
    export declare function compose<A extends unknown[], B, C, D>(fc: (c: C) => D, fb: (b: B) => C, fa: (...a: A) => B): (...a: A) => D;
    Type Parameters
    A

    B

    C

    D

    Parameters
    fc
    (c: C) => D

    fb
    (b: B) => C

    fa
    (...a: A) => B

    Returns
    (...a: A) => D

    compose(fd, fc, fb, fa)

    Declaration
    export declare function compose<A extends unknown[], B, C, D, E>(fd: (d: D) => E, fc: (c: C) => D, fb: (b: B) => C, fa: (...a: A) => B): (...a: A) => E;
    Type Parameters
    A

    B

    C

    D

    E

    Parameters
    fd
    (d: D) => E

    fc
    (c: C) => D

    fb
    (b: B) => C

    fa
    (...a: A) => B

    Returns
    (...a: A) => E

    compose(fe, fd, fc, fb, fa)

    Declaration
    export declare function compose<A extends unknown[], B, C, D, E, F>(fe: (e: E) => F, fd: (d: D) => E, fc: (c: C) => D, fb: (b: B) => C, fa: (...a: A) => B): (...a: A) => F;
    Type Parameters
    A

    B

    C

    D

    E

    F

    Parameters
    fe
    (e: E) => F

    fd
    (d: D) => E

    fc
    (c: C) => D

    fb
    (b: B) => C

    fa
    (...a: A) => B

    Returns
    (...a: A) => F

    compose(rest)

    Declaration
    export declare function compose<T>(...rest: ((t: T) => T)[]): (t: T) => T;
    Type Parameters
    T

    Parameters
    rest
    ((t: T) => T)[]

    Returns
    (t: T) => T

    decrementer(start)

    Returns a function that produces a monotonically increasing number value each time it is called.

    Declaration
    export declare function decrementer(start?: number): () => number;
    Parameters
    start
    number

    Returns
    () => number

    either(a, b)

    Returns a function that returns the result of calling its first argument if that result is "truthy", otherwise returning the result of calling its second argument. NOTE: This performs the same shortcutting as a logical OR (i.e. a() || b()).

    Declaration
    export declare function either<T, U extends T, V extends T>(a: (t: T) => t is U, b: (t: T) => t is V): (t: T) => t is U | V;
    Type Parameters
    T

    U

    V

    Parameters
    a
    (t: T) => t is U

    b
    (t: T) => t is V

    Returns
    (t: T) => t is U | V

    either(a, b)

    Declaration
    export declare function either<A extends unknown[], R1, R2>(a: (...args: A) => R1, b: (...args: A) => R2): (...args: A) => R1 extends (null | undefined | false | 0 | 0n | '') ? R2 : R1;
    Type Parameters
    A

    R1

    R2

    Parameters
    a
    (...args: A) => R1

    b
    (...args: A) => R2

    Returns
    (...args: A) => R1 extends (null | undefined | false | 0 | 0n | '') ? R2 : R1

    equate(a, b)

    Equates two values using the default Equaler.

    Declaration
    export declare function equate<T>(a: T, b: T): boolean;
    Type Parameters
    T

    Parameters
    a
    T

    b
    T

    Returns
    boolean

    factory(ctor)

    Returns a function that constructs an instance of the provided constructor.

    class Point {
      constructor(x, y) {
        this.x = x;
        this.y = y;
      }
    }
    const fn = factory(Point);
    fn(1, 2); // Point { x: 1, y: 2 }
    fn(3, 4); // Point { x: 3, y: 4 }
    
    Declaration
    export declare function factory<A extends unknown[], R>(ctor: new (...args: A) => R): (...args: A) => R;
    Type Parameters
    A

    R

    Parameters
    ctor
    new (...args: A) => R

    Returns
    (...args: A) => R

    factory(ctor, a0)

    Declaration
    export declare function factory<A0, A extends unknown[], R>(ctor: new (a0: A0, ...args: A) => R, a0: A0): (...args: A) => R;
    Type Parameters
    A0

    A

    R

    Parameters
    ctor
    new (a0: A0, ...args: A) => R

    a0
    A0

    Returns
    (...args: A) => R

    factory(ctor, a0, a1)

    Declaration
    export declare function factory<A0, A1, A extends unknown[], R>(ctor: new (a0: A0, a1: A1, ...args: A) => R, a0: A0, a1: A1): (...args: A) => R;
    Type Parameters
    A0

    A1

    A

    R

    Parameters
    ctor
    new (a0: A0, a1: A1, ...args: A) => R

    a0
    A0

    a1
    A1

    Returns
    (...args: A) => R

    factory(ctor, a0, a1, a2)

    Declaration
    export declare function factory<A0, A1, A2, A extends unknown[], R>(ctor: new (a0: A0, a1: A1, a2: A2, ...args: A) => R, a0: A0, a1: A1, a2: A2): (...args: A) => R;
    Type Parameters
    A0

    A1

    A2

    A

    R

    Parameters
    ctor
    new (a0: A0, a1: A1, a2: A2, ...args: A) => R

    a0
    A0

    a1
    A1

    a2
    A2

    Returns
    (...args: A) => R

    factory(ctor, a0, a1, a2, a3)

    Declaration
    export declare function factory<A0, A1, A2, A3, A extends unknown[], R>(ctor: new (a0: A0, a1: A1, a2: A2, a3: A3, ...args: A) => R, a0: A0, a1: A1, a2: A2, a3: A3): (...args: A) => R;
    Type Parameters
    A0

    A1

    A2

    A3

    A

    R

    Parameters
    ctor
    new (a0: A0, a1: A1, a2: A2, a3: A3, ...args: A) => R

    a0
    A0

    a1
    A1

    a2
    A2

    a3
    A3

    Returns
    (...args: A) => R

    factory(ctor, args)

    Declaration
    export declare function factory<A extends unknown[], R>(ctor: new (...args: A) => R, ...args: A): () => R;
    Type Parameters
    A

    R

    Parameters
    ctor
    new (...args: A) => R

    args
    A

    Returns
    () => R

    factory(ctor, args)

    Declaration
    export declare function factory<AX, R>(ctor: new (...args: AX[]) => R, ...args: AX[]): (...args: AX[]) => R;
    Type Parameters
    AX

    R

    Parameters
    ctor
    new (...args: AX[]) => R

    args
    AX[]

    Returns
    (...args: AX[]) => R

    fail_2(value)

    Throws the provided value.

    Declaration
    export declare function fail(value: unknown): never;
    Parameters
    value
    unknown

    Returns
    never

    fallback(a, b)

    Returns a function that returns the result of calling the first callback, if that result is neither null nor undefined; otherwise, returns the result of calling the second callback with the same arguments. NOTE: This performs the same shortcutting as nullish-coalesce (i.e. a() ?? b()).

    Declaration
    export declare function fallback<A extends unknown[], T, U>(a: (...args: A) => T, b: (...args: A) => U): (...args: A) => NonNullable<T> | U;
    Type Parameters
    A

    T

    U

    Parameters
    a
    (...args: A) => T

    b
    (...args: A) => U

    Returns
    (...args: A) => NonNullable<T> | U

    flip(f)

    Returns a function that calls the provided function, but swaps the first and second arguments.

    function compareNumbers(a, b) { return a - b };
    [3, 1, 2].sort(compareNumbers); // [1, 2, 3]
    [3, 1, 2].sort(flip(compareNumbers)); // [3, 2, 1]
    
    Declaration
    export declare function flip<A, B, C extends unknown[], R>(f: (a: A, b: B, ...c: C) => R): (b: B, a: A, ...c: C) => R;
    Type Parameters
    A

    B

    C

    R

    Parameters
    f
    (a: A, b: B, ...c: C) => R

    Returns
    (b: B, a: A, ...c: C) => R

    hash(value)

    Generates a hashcode from a value.

    Declaration
    export declare function hash(value: unknown): number;
    Parameters
    value
    unknown

    Returns
    number

    identity(value)

    Returns the provided value.

    Declaration
    export declare function identity<T>(value: T): T;
    Type Parameters
    T

    Parameters
    value
    T

    Returns
    T

    incrementer(start)

    Returns a function that produces a monotonically increasing number value each time it is called.

    Declaration
    export declare function incrementer(start?: number): () => number;
    Parameters
    start
    number

    Returns
    () => number

    invoker(key)

    Returns a function that invokes a method on the object provided as the function's first argument.

    const fn = invoker("sayHello", "Bob");
    fn({ sayHello(name) { console.log(`Hello, ${name}!`); } }); // prints: "Hello, Bob!"
    
    Declaration
    export declare function invoker<K extends PropertyKey>(key: K): <T extends Record<K, (...args: A) => ReturnType<T[K]>>, A extends unknown[]>(object: T, ...args: A) => ReturnType<T[K]>;
    Type Parameters
    K

    Parameters
    key
    K

    Returns
    <T extends Record<K, (...args: A) => ReturnType<T[K]>>, A extends unknown[]>(object: T, ...args: A) => ReturnType<T[K]>

    invoker(key, a0)

    Declaration
    export declare function invoker<K extends PropertyKey, A0>(key: K, a0: A0): <T extends Record<K, (a0: A0, ...args: A) => ReturnType<T[K]>>, A extends unknown[]>(object: T, ...args: A) => ReturnType<T[K]>;
    Type Parameters
    K

    A0

    Parameters
    key
    K

    a0
    A0

    Returns
    <T extends Record<K, (a0: A0, ...args: A) => ReturnType<T[K]>>, A extends unknown[]>(object: T, ...args: A) => ReturnType<T[K]>

    invoker(key, a0, a1)

    Declaration
    export declare function invoker<K extends PropertyKey, A0, A1>(key: K, a0: A0, a1: A1): <T extends Record<K, (a0: A0, a1: A1, ...args: A) => ReturnType<T[K]>>, A extends unknown[]>(object: T, ...args: A) => ReturnType<T[K]>;
    Type Parameters
    K

    A0

    A1

    Parameters
    key
    K

    a0
    A0

    a1
    A1

    Returns
    <T extends Record<K, (a0: A0, a1: A1, ...args: A) => ReturnType<T[K]>>, A extends unknown[]>(object: T, ...args: A) => ReturnType<T[K]>

    invoker(key, a0, a1, a2)

    Declaration
    export declare function invoker<K extends PropertyKey, A0, A1, A2>(key: K, a0: A0, a1: A1, a2: A2): <T extends Record<K, (a0: A0, a1: A1, a2: A2, ...args: A) => ReturnType<T[K]>>, A extends unknown[]>(object: T, ...args: A) => ReturnType<T[K]>;
    Type Parameters
    K

    A0

    A1

    A2

    Parameters
    key
    K

    a0
    A0

    a1
    A1

    a2
    A2

    Returns
    <T extends Record<K, (a0: A0, a1: A1, a2: A2, ...args: A) => ReturnType<T[K]>>, A extends unknown[]>(object: T, ...args: A) => ReturnType<T[K]>

    invoker(key, a0, a1, a2, a3)

    Declaration
    export declare function invoker<K extends PropertyKey, A0, A1, A2, A3>(key: K, a0: A0, a1: A1, a2: A2, a3: A3): <T extends Record<K, (a0: A0, a1: A1, a2: A2, a3: A3, ...args: A) => ReturnType<T[K]>>, A extends unknown[]>(object: T, ...args: A) => ReturnType<T[K]>;
    Type Parameters
    K

    A0

    A1

    A2

    A3

    Parameters
    key
    K

    a0
    A0

    a1
    A1

    a2
    A2

    a3
    A3

    Returns
    <T extends Record<K, (a0: A0, a1: A1, a2: A2, a3: A3, ...args: A) => ReturnType<T[K]>>, A extends unknown[]>(object: T, ...args: A) => ReturnType<T[K]>

    invoker(key, args)

    Declaration
    export declare function invoker<K extends PropertyKey, A extends unknown[]>(key: K, ...args: A): <T extends Record<K, (...args: A) => ReturnType<T[K]>>>(object: T) => ReturnType<T[K]>;
    Type Parameters
    K

    A

    Parameters
    key
    K

    args
    A

    Returns
    <T extends Record<K, (...args: A) => ReturnType<T[K]>>>(object: T) => ReturnType<T[K]>

    invoker(key, args)

    Declaration
    export declare function invoker<K extends PropertyKey, AX>(key: K, ...args: AX[]): <T extends Record<K, (...args: AX[]) => ReturnType<T[K]>>>(object: T, ...args: AX[]) => ReturnType<T[K]>;
    Type Parameters
    K

    AX

    Parameters
    key
    K

    args
    AX[]

    Returns
    <T extends Record<K, (...args: AX[]) => ReturnType<T[K]>>>(object: T, ...args: AX[]) => ReturnType<T[K]>

    isDefined(value)

    Returns true if a value is neither null nor undefined.

    Declaration
    export declare function isDefined<T>(value: T): value is NonNullable<T>;
    Type Parameters
    T

    Parameters
    value
    T

    Returns
    value is NonNullable<T>

    lazy(factory, args)

    Returns a function that will evaluate once when called and will subsequently always return the same result.

    let count = 0;
    const fn = lazy(() => count++);
    fn(); // 0
    fn(); // 0
    count; // 1
    
    Declaration
    export declare function lazy<A extends unknown[], T>(factory: (...args: A) => T, ...args: A): () => T;
    Type Parameters
    A

    T

    Parameters
    factory
    (...args: A) => T

    args
    A

    Returns
    () => T

    memoize(factory, options)

    Memoize a callback. An invocation for a memoized function will only evaluate once for the same argument list. You can control caching behavior for memoize by passing a custom cache object.

    The default cache behavior is provided by DefaultMemoizeCache.

    Declaration
    export declare function memoize<A extends unknown[], T>(factory: (...args: A) => T, options?: MemoizeOptions<A, T>): (...args: A) => T;
    Type Parameters
    A

    T

    Parameters
    factory
    (...args: A) => T

    The callback function to evaluate.

    options
    MemoizeOptions<A, T>

    Options that control caching behavior.

    Returns
    (...args: A) => T

    The memoized function.

    nAry(f, length)

    Truncates a function's arguments to a fixed length.

    Declaration
    export declare function nAry<T, R>(f: (this: T) => R, length: 0): (this: T) => R;
    Type Parameters
    T

    R

    Parameters
    f
    (this: T) => R

    length
    0

    Returns
    (this: T) => R

    nAry(f, length)

    Declaration
    export declare function nAry<T, A, R>(f: (this: T, a: A) => R, length: 1): (this: T, a: A) => R;
    Type Parameters
    T

    A

    R

    Parameters
    f
    (this: T, a: A) => R

    length
    1

    Returns
    (this: T, a: A) => R

    nAry(f, length)

    Declaration
    export declare function nAry<T, A, B, R>(f: (this: T, a: A, b: B) => R, length: 2): (this: T, a: A, b: B) => R;
    Type Parameters
    T

    A

    B

    R

    Parameters
    f
    (this: T, a: A, b: B) => R

    length
    2

    Returns
    (this: T, a: A, b: B) => R

    nAry(f, length)

    Declaration
    export declare function nAry<T, A, B, C, R>(f: (this: T, a: A, b: B, c: C) => R, length: 3): (this: T, a: A, b: B, c: C) => R;
    Type Parameters
    T

    A

    B

    C

    R

    Parameters
    f
    (this: T, a: A, b: B, c: C) => R

    length
    3

    Returns
    (this: T, a: A, b: B, c: C) => R

    nAry(f, length)

    Declaration
    export declare function nAry<T, A, B, C, D, R>(f: (this: T, a: A, b: B, c: C, d: D) => R, length: 4): (this: T, a: A, b: B, c: C, d: D) => R;
    Type Parameters
    T

    A

    B

    C

    D

    R

    Parameters
    f
    (this: T, a: A, b: B, c: C, d: D) => R

    length
    4

    Returns
    (this: T, a: A, b: B, c: C, d: D) => R

    noop(args)

    Does nothing.

    Declaration
    export declare function noop(...args: any[]): unknown;
    Parameters
    args
    any[]

    Returns
    unknown

    pipe(fa, fb)

    Left-to-right composition of functions (i.e. pipe(g, f) is x => f(g(x))).

    Declaration
    export declare function pipe<A extends unknown[], B, C>(fa: (...a: A) => B, fb: (b: B) => C): (...a: A) => C;
    Type Parameters
    A

    B

    C

    Parameters
    fa
    (...a: A) => B

    fb
    (b: B) => C

    Returns
    (...a: A) => C

    pipe(fa, fb, fc)

    Declaration
    export declare function pipe<A extends unknown[], B, C, D>(fa: (...a: A) => B, fb: (b: B) => C, fc: (c: C) => D): (...a: A) => D;
    Type Parameters
    A

    B

    C

    D

    Parameters
    fa
    (...a: A) => B

    fb
    (b: B) => C

    fc
    (c: C) => D

    Returns
    (...a: A) => D

    pipe(fa, fb, fc, fd)

    Declaration
    export declare function pipe<A extends unknown[], B, C, D, E>(fa: (...a: A) => B, fb: (b: B) => C, fc: (c: C) => D, fd: (d: D) => E): (...a: A) => E;
    Type Parameters
    A

    B

    C

    D

    E

    Parameters
    fa
    (...a: A) => B

    fb
    (b: B) => C

    fc
    (c: C) => D

    fd
    (d: D) => E

    Returns
    (...a: A) => E

    pipe(fa, fb, fc, fd, fe)

    Declaration
    export declare function pipe<A extends unknown[], B, C, D, E, F>(fa: (...a: A) => B, fb: (b: B) => C, fc: (c: C) => D, fd: (d: D) => E, fe: (e: E) => F): (...a: A) => F;
    Type Parameters
    A

    B

    C

    D

    E

    F

    Parameters
    fa
    (...a: A) => B

    fb
    (b: B) => C

    fc
    (c: C) => D

    fd
    (d: D) => E

    fe
    (e: E) => F

    Returns
    (...a: A) => F

    pipe(first, rest)

    Declaration
    export declare function pipe<A extends unknown[], B>(first: (...a: A) => B, ...rest: ((b: B) => B)[]): (...a: A) => B;
    Type Parameters
    A

    B

    Parameters
    first
    (...a: A) => B

    rest
    ((b: B) => B)[]

    Returns
    (...a: A) => B

    property(key)

    Returns a function that reads the value of a property from an object provided as the function's first argument.

    Declaration
    export declare function property<K extends PropertyKey>(key: K): <T extends Record<K, T[K]>>(object: T) => T[K];
    Type Parameters
    K

    Parameters
    key
    K

    The key for the property.

    Returns
    <T extends Record<K, T[K]>>(object: T) => T[K]

    propertyWriter(key)

    Returns a function that writes a value to a property on an object provided as the function's first argument.

    Declaration
    export declare function propertyWriter<K extends PropertyKey>(key: K): <T extends Record<K, T[K]>>(object: T, value: T[K]) => void;
    Type Parameters
    K

    Parameters
    key
    K

    The key for the property.

    Returns
    <T extends Record<K, T[K]>>(object: T, value: T[K]) => void

    tuple(args)

    Makes a "tuple" from the provided arguments.

    Declaration
    export declare function tuple<A extends readonly unknown[]>(...args: A): A;
    Type Parameters
    A

    Parameters
    args
    A

    Returns
    A

    uncurryThis(f)

    Returns a function whose first argument is passed as the this receiver to the provided function when called.

    const hasOwn = uncurryThis(Object.prototype.hasOwnProperty);
    const obj = { x: 1 };
    hasOwn(obj, "x"); // true
    hasOwn(obj, "y"); // false
    
    Declaration
    export declare function uncurryThis<T, A extends unknown[], R>(f: (this: T, ...args: A) => R): (this_: T, ...args: A) => R;
    Type Parameters
    T

    A

    R

    Parameters
    f
    (this: T, ...args: A) => R

    Returns
    (this_: T, ...args: A) => R

    Type Aliases

    MemoizeCacheSettledResult

    Describes a cache result.

    Declaration
    export declare type MemoizeCacheSettledResult<T> = MemoizeCacheFulfilledResult<T> | MemoizeCacheRejectedResult;
    Type Parameters
    T

    Namespaces

    clamp

    compare

    decrementer

    equate

    hash

    incrementer

    Op

    Op.ge

    Op.gt

    Op.le

    Op.lt

    Op.max

    Op.maxBy

    Op.min

    Op.minBy

    Op.req

    Op.rne

    • Improve this Doc
    Generated by DocFX