MCPcopy
hub / github.com/lodash/lodash / createCurry

Function createCurry

lodash.js:5109–5135  ·  view source on GitHub ↗

* Creates a function that wraps `func` to enable currying. * * @private * @param {Function} func The function to wrap. * @param {number} bitmask The bitmask flags. See `createWrap` for more details. * @param {number} arity The arity of `func`. * @returns {Function} Retu

(func, bitmask, arity)

Source from the content-addressed store, hash-verified

5107 * @returns {Function} Returns the new wrapped function.
5108 */
5109 function createCurry(func, bitmask, arity) {
5110 var Ctor = createCtor(func);
5111
5112 function wrapper() {
5113 var length = arguments.length,
5114 args = Array(length),
5115 index = length,
5116 placeholder = getHolder(wrapper);
5117
5118 while (index--) {
5119 args[index] = arguments[index];
5120 }
5121 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
5122 ? []
5123 : replaceHolders(args, placeholder);
5124
5125 length -= holders.length;
5126 if (length < arity) {
5127 return createRecurry(
5128 func, bitmask, createHybrid, wrapper.placeholder, undefined,
5129 args, holders, undefined, undefined, arity - length);
5130 }
5131 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5132 return apply(fn, this, args);
5133 }
5134 return wrapper;
5135 }
5136
5137 /**
5138 * Creates a `_.find` or `_.findLast` function.

Callers 1

createWrapFunction · 0.85

Calls 1

createCtorFunction · 0.85

Tested by

no test coverage detected