@newdash/newdash
Version:
javascript/typescript utility library
39 lines (38 loc) • 1.22 kB
TypeScript
/**
* 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
* @param func The function to partially apply arguments to.
* @param partials The arguments to be partially applied.
* @returns Returns the new partially applied function.
* @example
*
* ```js
* function greet(greeting, name) {
* return greeting + ' ' + name;
* }
*
* var greetFred = partialRight(greet, 'fred');
* greetFred('hi');
* // => 'hi fred'
*
* // Partially applied with placeholders.
* var sayHelloTo = partialRight(greet, 'hello', _);
* sayHelloTo('fred');
* // => 'hello fred'
* ```
*/
export declare function partialRight<F extends (...args: any[]) => any>(func: F, ...partials: any[]): (...args: any[]) => ReturnType<F>;
export declare namespace partialRight {
var placeholder: string;
}
export default partialRight;