super-utils-plus
Version:
A superior alternative to Lodash with improved performance, TypeScript support, and developer experience
47 lines (46 loc) • 1.46 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.
*
* @param func - The function to partially apply arguments to
* @param partials - The arguments to be partially applied
* @returns The new partially applied function
*
* @example
* ```ts
* function greet(greeting, name) {
* return greeting + ' ' + name;
* }
*
* const sayHelloTo = partial(greet, 'hello');
* sayHelloTo('fred');
* // => 'hello fred'
* ```
*/
export declare function partial<T extends (...args: any[]) => any>(func: T, ...partials: any[]): (...args: any[]) => ReturnType<T>;
export declare namespace partial {
var placeholder: symbol;
}
/**
* This method is like `partial` except that partially applied arguments
* are appended to the arguments it receives.
*
* @param func - The function to partially apply arguments to
* @param partials - The arguments to be partially applied
* @returns The new partially applied function
*
* @example
* ```ts
* function greet(greeting, name) {
* return greeting + ' ' + name;
* }
*
* const greetFred = partialRight(greet, 'fred');
* greetFred('hi');
* // => 'hi fred'
* ```
*/
export declare function partialRight<T extends (...args: any[]) => any>(func: T, ...partials: any[]): (...args: any[]) => ReturnType<T>;
export declare namespace partialRight {
var placeholder: symbol;
}