froebel
Version:
TypeScript utility library
17 lines (16 loc) • 528 B
TypeScript
import { Take_, λ } from "./types";
/**
* 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]
* ```
*/
declare const unary: <T extends λ<[any], any>>(fun: Parameters<T> extends [] ? never : T) => Unary<T>;
export default unary;
declare type Unary<T extends λ<[any]>> = λ<Take_<Parameters<T>, 1>, ReturnType<T>>;