Options
All
  • Public
  • Public/Protected
  • All
Menu

Module partial

Index

References

Namespaces

Functions Function

References

Renames and re-exports partial

Function Functions

  • partial<F>(func: F, ...partials: any[]): ((...args: any[]) => ReturnType<F>)
  • Creates a function that invokes func with partials prepended to the arguments it receives. This method is like bind except it does not alter the this binding.

    The partial.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for partially applied arguments.

    Note: This method doesn't set the "length" property of partially applied functions.

    since

    5.5.0

    example
    function greet(greeting, name) {
    return greeting + ' ' + name;
    }

    var sayHelloTo = partial(greet, 'hello');
    sayHelloTo('fred');
    // => 'hello fred'

    // Partially applied with placeholders.
    var greetFred = partial(greet, partial.placeholder, 'fred');
    greetFred('hi');
    // => 'hi fred'

    Type Parameters

    • F extends ((...args: any[]) => any)

    Parameters

    • func: F

      The function to partially apply arguments to.

    • Rest ...partials: any[]

      The arguments to be partially applied.

    Returns ((...args: any[]) => ReturnType<F>)

    Returns the new partially applied function.

      • (...args: any[]): ReturnType<F>
      • Creates a function that invokes func with partials prepended to the arguments it receives. This method is like bind except it does not alter the this binding.

        The partial.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for partially applied arguments.

        Note: This method doesn't set the "length" property of partially applied functions.

        since

        5.5.0

        category

        Function

        example
        function greet(greeting, name) {
        return greeting + ' ' + name;
        }

        var sayHelloTo = partial(greet, 'hello');
        sayHelloTo('fred');
        // => 'hello fred'

        // Partially applied with placeholders.
        var greetFred = partial(greet, partial.placeholder, 'fred');
        greetFred('hi');
        // => 'hi fred'

        Parameters

        • Rest ...args: any[]

        Returns ReturnType<F>

        Returns the new partially applied function.