Skip to content

Latest commit

 

History

History
65 lines (55 loc) · 2.25 KB

API.md

File metadata and controls

65 lines (55 loc) · 2.25 KB

Functions

partialApply(func, ...originalArgs)function

Partially apply arguments to a function Wraps a function so that some arguments are applied beforehand, and others on a later call. The this value is also passed to the internal function.

partialApplyRight(func, ...originalArgs)function

Partially apply arguments to the right-side of a function

partialApply(func, ...originalArgs) ⇒ function

Partially apply arguments to a function Wraps a function so that some arguments are applied beforehand, and others on a later call. The this value is also passed to the internal function.

Kind: global function
Returns: function - A wrapped function that returns whatever the nested function returns

Param Type Description
func function The function to partially apply arguments
...originalArgs * Arguments to wrap. All arguments that are not _ will be passed in order to the wrapped function. Arguments provided as _ are expected to be provided in order later.

Example

// Simple adding function
     function add(a, b) {
         return a + b;
     }
     // Wrap
     const addOne = partialApply(1, _);
     // Call later
     addOne(5); // 6

partialApplyRight(func, ...originalArgs) ⇒ function

Partially apply arguments to the right-side of a function

Kind: global function
Returns: function - A wrapped function that returns whatever the nested function returns

Param Type Description
func function The function to partially apply arguments to
...originalArgs * The arguments to pass to the right side of the function

Example

// Function with a callback
     function doSomething(arg1, arg2, callback) {
         callback(arg1 + arg2);
     }
     // Wrap
     const logSomething = partialApplyRight(doSomething, console.log);
     // Call later
     logSomething(1, 2); // console.log's "3"