Skip to main content

unary

TS JS Deno

Creates a function that accepts up to one argument, ignoring any additional arguments.

Call the provided function, fn, with just the first argument given.

typescript
const unary = (fn: Function) => (val: any) => fn(val);
typescript
["6", "8", "10"].map(unary(parseInt)); // [6, 8, 10]