UNPKG

froebel

Version:
17 lines (16 loc) 380 B
/** * Partially apply a function. * * @example * ``` * const divide = (dividend: number, divisor: number) => dividend / divisor * * // (divisor: number) => number * const oneOver = partial(divide, 1) * * // prints: 0.25 * console.log(oneOver(4)) * ``` */ const partial = (fun, ...argsLeft) => (...argsRight) => fun(...argsLeft, ...argsRight); export default partial;