@cgnal/utils/function

Function utils.

Source:

Methods

(static) nullary(fn) → {function}

Source:
Since:
  • 0.0.13

Builds a function that avoids to pass arguments to the given one.
A shortcut for a common use case of aritize.

Example
const addTwo = (n = 0) => n + 2;
const fakeAddTwo = nullary(addTwo);

addTwo(5) // => 7
fakeAddTwo(5) // => 2
Parameters:
Name Type Description
fn function
Returns:

() => Any

Type
function