1 var copyArray = require('./_copyArray'),
2 isLaziable = require('./_isLaziable'),
3 setData = require('./_setData');
5 /** Used to compose bitmasks for wrapper metadata. */
11 PARTIAL_RIGHT_FLAG = 64;
14 * Creates a function that wraps `func` to continue currying.
17 * @param {Function} func The function to wrap.
18 * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details.
19 * @param {Function} wrapFunc The function to create the `func` wrapper.
20 * @param {*} placeholder The placeholder to replace.
21 * @param {*} [thisArg] The `this` binding of `func`.
22 * @param {Array} [partials] The arguments to prepend to those provided to the new function.
23 * @param {Array} [holders] The `partials` placeholder indexes.
24 * @param {Array} [argPos] The argument positions of the new function.
25 * @param {number} [ary] The arity cap of `func`.
26 * @param {number} [arity] The arity of `func`.
27 * @returns {Function} Returns the new wrapped function.
29 function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
30 var isCurry = bitmask & CURRY_FLAG,
31 newArgPos = argPos ? copyArray(argPos) : undefined,
32 newsHolders = isCurry ? holders : undefined,
33 newHoldersRight = isCurry ? undefined : holders,
34 newPartials = isCurry ? partials : undefined,
35 newPartialsRight = isCurry ? undefined : partials;
37 bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);
38 bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);
40 if (!(bitmask & CURRY_BOUND_FLAG)) {
41 bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
43 var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity],
44 result = wrapFunc.apply(undefined, newData);
46 if (isLaziable(func)) {
47 setData(result, newData);
49 result.placeholder = placeholder;
53 module.exports = createRecurryWrapper;