Skip to main content

partial

TS JS Deno

Creates a function that invokes fn with partials prepended to the arguments it receives.

Use the spread operator (...) to prepend partials to the list of arguments of fn.

typescript
const partial =
(fn: Function, ...partials: any[]) =>
(...args: any[]) =>
fn(...partials, ...args);
typescript
const greet = (greeting, name) => greeting + " " + name + "!";
const greetHello = partial(greet, "Hello");
greetHello("John"); // 'Hello John!'