Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface AnyOneArgFunction<ARG, R>

Type parameters

  • ARG = any

  • R = any

Hierarchy

  • Function
    • AnyOneArgFunction

Callable

  • AnyOneArgFunction(arg: ARG): R
  • AnyOneArgFunction(arg: ARG): R
  • Parameters

    • arg: ARG

    Returns R

  • Parameters

    • arg: ARG

    Returns R

Index

Methods

  • Performs left-to-right function composition. The first argument may have any arity; the remaining arguments must be unary.

    If any function from parameters returns a Promise, the next function from the parameters will take the resolved value of that promise, the final result of calling the composition function is also a promise.

    Type parameters

    • T

    Parameters

    • this: T

    Returns T

  • Type parameters

    • A: any[]

    • T1

    • T2

    Parameters

    Returns AnyFunction<A, T1 extends Promise<any> ? Promise<T2> : T2>

  • Type parameters

    • A: any[]

    • T1

    • T2

    • T3

    Parameters

    Returns AnyFunction<A, T2 extends Promise<any> ? Promise<T3> : T1 extends Promise<any> ? Promise<T3> : T3>

  • Type parameters

    • A: any[]

    • T1

    • T2

    • T3

    • T4

    Parameters

    Returns AnyFunction<A, T3 extends Promise<any> ? Promise<T4> : T2 extends Promise<any> ? Promise<T4> : T1 extends Promise<any> ? Promise<T4> : T4>

  • Type parameters

    • A: any[]

    • T1

    • T2

    • T3

    • T4

    • T5

    Parameters

    Returns AnyFunction<A, T4 extends Promise<any> ? Promise<T5> : T3 extends Promise<any> ? Promise<T5> : T2 extends Promise<any> ? Promise<T5> : T1 extends Promise<any> ? Promise<T5> : T5>

  • Type parameters

    • A: any[]

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    Parameters

    Returns AnyFunction<A, T5 extends Promise<any> ? Promise<T6> : T4 extends Promise<any> ? Promise<T6> : T3 extends Promise<any> ? Promise<T6> : T2 extends Promise<any> ? Promise<T6> : T1 extends Promise<any> ? Promise<T6> : T6>

  • Performs left-to-right function composition. The first argument may have any arity; the remaining arguments must be unary.

    If any function from parameters returns a Promise, the next function from the parameters will take the resolved value of that promise, the final result of calling the composition function is also a promise.

    Type parameters

    • T

    Parameters

    • this: T

    Returns T

  • Type parameters

    • A: any[]

    • T1

    • T2

    Parameters

    Returns AnyFunction<A, T1 extends Promise<any> ? Promise<T2> : T2>

  • Type parameters

    • A: any[]

    • T1

    • T2

    • T3

    Parameters

    Returns AnyFunction<A, T2 extends Promise<any> ? Promise<T3> : T1 extends Promise<any> ? Promise<T3> : T3>

  • Type parameters

    • A: any[]

    • T1

    • T2

    • T3

    • T4

    Parameters

    Returns AnyFunction<A, T3 extends Promise<any> ? Promise<T4> : T2 extends Promise<any> ? Promise<T4> : T1 extends Promise<any> ? Promise<T4> : T4>

  • Type parameters

    • A: any[]

    • T1

    • T2

    • T3

    • T4

    • T5

    Parameters

    Returns AnyFunction<A, T4 extends Promise<any> ? Promise<T5> : T3 extends Promise<any> ? Promise<T5> : T2 extends Promise<any> ? Promise<T5> : T1 extends Promise<any> ? Promise<T5> : T5>

  • Type parameters

    • A: any[]

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    Parameters

    Returns AnyFunction<A, T5 extends Promise<any> ? Promise<T6> : T4 extends Promise<any> ? Promise<T6> : T3 extends Promise<any> ? Promise<T6> : T2 extends Promise<any> ? Promise<T6> : T1 extends Promise<any> ? Promise<T6> : T6>

  • curry<T>(this: T): Curry<T>
  • curry<T>(this: T): Curry<T>
  • Returns a curried equivalent of the function.

    The curried function has two unusual capabilities. First, its arguments needn't be provided one at a time. If f is a ternary function and g is f.curry(), the following are equivalent:

    g(1)(2)(3)
    g(1)(2, 3)
    g(1, 2)(3)
    g(1, 2, 3)

    Secondly, the special placeholder value Function.__ may be used to specify "gaps", allowing partial application of any combination of arguments, regardless of their positions. If g is as above and _ is Function.__, the following are equivalent:

    g(1, 2, 3)
    g(_, 2, 3)(1)
    g(_, _, 3)(1)(2)
    g(_, _, 3)(1, 2)
    g(_, 2)(1)(3)
    g(_, 2)(1, 3)
    g(_, 2)(_, 3)(1)

    Type parameters

    Parameters

    • this: T

    Returns Curry<T>

  • Returns a curried equivalent of the function.

    The curried function has two unusual capabilities. First, its arguments needn't be provided one at a time. If f is a ternary function and g is f.curry(), the following are equivalent:

    g(1)(2)(3)
    g(1)(2, 3)
    g(1, 2)(3)
    g(1, 2, 3)

    Secondly, the special placeholder value Function.__ may be used to specify "gaps", allowing partial application of any combination of arguments, regardless of their positions. If g is as above and _ is Function.__, the following are equivalent:

    g(1, 2, 3)
    g(_, 2, 3)(1)
    g(_, _, 3)(1)(2)
    g(_, _, 3)(1, 2)
    g(_, 2)(1)(3)
    g(_, 2)(1, 3)
    g(_, 2)(_, 3)(1)

    Type parameters

    Parameters

    • this: T

    Returns Curry<T>

  • debounce<T>(this: T, delay?: number): AnyFunction<Parameters<T>, void>
  • debounce<T>(this: T, delay?: number): AnyFunction<Parameters<T>, void>
  • Returns a new function that allows to invoke the target function only with the specified delay. The next invocation of the function will cancel the previous.

    Type parameters

    Parameters

    • this: T
    • Optional delay: number

    Returns AnyFunction<Parameters<T>, void>

  • Returns a new function that allows to invoke the target function only with the specified delay. The next invocation of the function will cancel the previous.

    Type parameters

    Parameters

    • this: T
    • Optional delay: number

    Returns AnyFunction<Parameters<T>, void>

  • once<T>(this: T): T
  • once<T>(this: T): T
  • Returns a new function that allows to invoke the target function only once

    Type parameters

    • T

    Parameters

    • this: T

    Returns T

  • Returns a new function that allows to invoke the target function only once

    Type parameters

    • T

    Parameters

    • this: T

    Returns T

  • Returns a new function based on the target that wraps the returning value into the Either structure. If the first argument of the created function is taken null or undefined, the function returns the rejected value.

    example
    function toLowerCase(str: string): string {
    return str.toLowerCase();
    }

    toLowerCase.option()(null).catch((err) => err === null);
    toLowerCase.option()(1).catch((err) => err.message === 'str.toLowerCase is not a function');

    toLowerCase.option()('FOO').then((value) => value === 'foo');
    toLowerCase.option()(toLowerCase.option()('FOO')).then((value) => value === 'foo');

    Type parameters

    • R

    Parameters

    • this: () => R
        • (): R
        • Returns R

    Returns AnyFunction<any[], Maybe<R>>

  • Returns a new function based on the target that wraps the returning value into the Either structure. If the first argument of the created function is taken null or undefined, the function returns the rejected value.

    example
    function toLowerCase(str: string): string {
    return str.toLowerCase();
    }

    toLowerCase.option()(null).catch((err) => err === null);
    toLowerCase.option()(1).catch((err) => err.message === 'str.toLowerCase is not a function');

    toLowerCase.option()('FOO').then((value) => value === 'foo');
    toLowerCase.option()(toLowerCase.option()('FOO')).then((value) => value === 'foo');

    Type parameters

    • A1

    • A: any[]

    • R

    Parameters

    • this: (a1: A1, ...rest: A) => R
        • (a1: A1, ...rest: A): R
        • Parameters

          • a1: A1
          • Rest ...rest: A

          Returns R

    Returns (a1: Nullable<A1> | Maybe<Nullable<A1>> | Either<A1>, ...rest: A) => Maybe<R>

      • Returns a new function based on the target that wraps the returning value into the Either structure. If the first argument of the created function is taken null or undefined, the function returns the rejected value.

        example
        function toLowerCase(str: string): string {
        return str.toLowerCase();
        }

        toLowerCase.option()(null).catch((err) => err === null);
        toLowerCase.option()(1).catch((err) => err.message === 'str.toLowerCase is not a function');

        toLowerCase.option()('FOO').then((value) => value === 'foo');
        toLowerCase.option()(toLowerCase.option()('FOO')).then((value) => value === 'foo');

        Parameters

        Returns Maybe<R>

  • Returns a new function based on the target that wraps the returning value into the Either structure. If the first argument of the created function is taken null or undefined, the function returns the rejected value.

    example
    function toLowerCase(str: string): string {
    return str.toLowerCase();
    }

    toLowerCase.option()(null).catch((err) => err === null);
    toLowerCase.option()(1).catch((err) => err.message === 'str.toLowerCase is not a function');

    toLowerCase.option()('FOO').then((value) => value === 'foo');
    toLowerCase.option()(toLowerCase.option()('FOO')).then((value) => value === 'foo');

    Type parameters

    • R

    Parameters

    • this: () => R
        • (): R
        • Returns R

    Returns AnyFunction<any[], Maybe<R>>

  • Returns a new function based on the target that wraps the returning value into the Either structure. If the first argument of the created function is taken null or undefined, the function returns the rejected value.

    example
    function toLowerCase(str: string): string {
    return str.toLowerCase();
    }

    toLowerCase.option()(null).catch((err) => err === null);
    toLowerCase.option()(1).catch((err) => err.message === 'str.toLowerCase is not a function');

    toLowerCase.option()('FOO').then((value) => value === 'foo');
    toLowerCase.option()(toLowerCase.option()('FOO')).then((value) => value === 'foo');

    Type parameters

    • A1

    • A: any[]

    • R

    Parameters

    • this: (a1: A1, ...rest: A) => R
        • (a1: A1, ...rest: A): R
        • Parameters

          • a1: A1
          • Rest ...rest: A

          Returns R

    Returns (a1: Nullable<A1> | Maybe<Nullable<A1>> | Either<A1>, ...rest: A) => Maybe<R>

      • Returns a new function based on the target that wraps the returning value into the Either structure. If the first argument of the created function is taken null or undefined, the function returns the rejected value.

        example
        function toLowerCase(str: string): string {
        return str.toLowerCase();
        }

        toLowerCase.option()(null).catch((err) => err === null);
        toLowerCase.option()(1).catch((err) => err.message === 'str.toLowerCase is not a function');

        toLowerCase.option()('FOO').then((value) => value === 'foo');
        toLowerCase.option()(toLowerCase.option()('FOO')).then((value) => value === 'foo');

        Parameters

        Returns Maybe<R>

  • Returns a new function based on the target that wraps the returning value into the Either structure

    example
    function toLowerCase(str: string): string {
    return str.toLowerCase();
    }

    toLowerCase.result()(1).catch((err) => err.message === 'str.toLowerCase is not a function');
    toLowerCase.result()('FOO').then((value) => value === 'foo');
    toLowerCase.result()(toLowerCase.result()('FOO')).then((value) => value === 'foo');

    Type parameters

    • R

    Parameters

    • this: () => R
        • (): R
        • Returns R

    Returns AnyFunction<any[], Either<R>>

  • Returns a new function based on the target that wraps the returning value into the Either structure

    example
    function toLowerCase(str: string): string {
    return str.toLowerCase();
    }

    toLowerCase.result()(1).catch((err) => err.message === 'str.toLowerCase is not a function');
    toLowerCase.result()('FOO').then((value) => value === 'foo');
    toLowerCase.result()(toLowerCase.result()('FOO')).then((value) => value === 'foo');

    Type parameters

    • A1

    • A: any[]

    • R

    Parameters

    • this: (a1: A1, ...rest: A) => R
        • (a1: A1, ...rest: A): R
        • Parameters

          • a1: A1
          • Rest ...rest: A

          Returns R

    Returns (a1: Maybe<A1> | Either<A1>, ...rest: A) => Either<R>

      • Returns a new function based on the target that wraps the returning value into the Either structure

        example
        function toLowerCase(str: string): string {
        return str.toLowerCase();
        }

        toLowerCase.result()(1).catch((err) => err.message === 'str.toLowerCase is not a function');
        toLowerCase.result()('FOO').then((value) => value === 'foo');
        toLowerCase.result()(toLowerCase.result()('FOO')).then((value) => value === 'foo');

        Parameters

        Returns Either<R>

  • Returns a new function based on the target that wraps the returning value into the Either structure

    example
    function toLowerCase(str: string): string {
    return str.toLowerCase();
    }

    toLowerCase.result()(1).catch((err) => err.message === 'str.toLowerCase is not a function');
    toLowerCase.result()('FOO').then((value) => value === 'foo');
    toLowerCase.result()(toLowerCase.result()('FOO')).then((value) => value === 'foo');

    Type parameters

    • R

    Parameters

    • this: () => R
        • (): R
        • Returns R

    Returns AnyFunction<any[], Either<R>>

  • Returns a new function based on the target that wraps the returning value into the Either structure

    example
    function toLowerCase(str: string): string {
    return str.toLowerCase();
    }

    toLowerCase.result()(1).catch((err) => err.message === 'str.toLowerCase is not a function');
    toLowerCase.result()('FOO').then((value) => value === 'foo');
    toLowerCase.result()(toLowerCase.result()('FOO')).then((value) => value === 'foo');

    Type parameters

    • A1

    • A: any[]

    • R

    Parameters

    • this: (a1: A1, ...rest: A) => R
        • (a1: A1, ...rest: A): R
        • Parameters

          • a1: A1
          • Rest ...rest: A

          Returns R

    Returns (a1: Maybe<A1> | Either<A1>, ...rest: A) => Either<R>

      • Returns a new function based on the target that wraps the returning value into the Either structure

        example
        function toLowerCase(str: string): string {
        return str.toLowerCase();
        }

        toLowerCase.result()(1).catch((err) => err.message === 'str.toLowerCase is not a function');
        toLowerCase.result()('FOO').then((value) => value === 'foo');
        toLowerCase.result()(toLowerCase.result()('FOO')).then((value) => value === 'foo');

        Parameters

        Returns Either<R>

  • Returns a new function that allows to invoke the target function not more often than the specified delay. The first invoking of a function will run immediately, but all rest invokes will be merged to one and executes after the specified delay.

    Type parameters

    Parameters

    • this: T
    • Optional delay: number

    Returns AnyFunction<Parameters<T>, void>

  • Returns a new function that allows to invoke the target function not more often than the specified delay. The first invoking of a function will run immediately, but all rest invokes will be merged to one and executes after the specified delay.

    Type parameters

    Parameters

    Returns AnyFunction<Parameters<T>, void>

  • Returns a new function that allows to invoke the target function not more often than the specified delay. The first invoking of a function will run immediately, but all rest invokes will be merged to one and executes after the specified delay.

    Type parameters

    Parameters

    • this: T
    • Optional delay: number

    Returns AnyFunction<Parameters<T>, void>

  • Returns a new function that allows to invoke the target function not more often than the specified delay. The first invoking of a function will run immediately, but all rest invokes will be merged to one and executes after the specified delay.

    Type parameters

    Parameters

    Returns AnyFunction<Parameters<T>, void>