froebel
Version:
TypeScript utility library
15 lines (14 loc) • 339 B
JavaScript
/**
* Turns `fun` into a unary function (a function that only accepts one
* argument).
*
* Note: `fun` must accept at least one argument and must not require more than
* one argument.
*
* @example
* ```
* ['1', '2', '3'].map(unary(parseInt)) // -> [1, 2, 3]
* ```
*/
const unary = fun => arg => fun(arg);
export default unary;