1 var isLaziable = require('./_isLaziable'),
2 setData = require('./_setData'),
3 setWrapToString = require('./_setWrapToString');
5 /** Used to compose bitmasks for function 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 flags. See `createWrap` for more details.
19 * @param {Function} wrapFunc The function to create the `func` wrapper.
20 * @param {*} placeholder The placeholder value.
21 * @param {*} [thisArg] The `this` binding of `func`.
22 * @param {Array} [partials] The arguments to prepend to those provided to
24 * @param {Array} [holders] The `partials` placeholder indexes.
25 * @param {Array} [argPos] The argument positions of the new function.
26 * @param {number} [ary] The arity cap of `func`.
27 * @param {number} [arity] The arity of `func`.
28 * @returns {Function} Returns the new wrapped function.
30 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
31 var isCurry = bitmask & CURRY_FLAG,
32 newHolders = 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);
44 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
45 newHoldersRight, argPos, ary, arity
48 var result = wrapFunc.apply(undefined, newData);
49 if (isLaziable(func)) {
50 setData(result, newData);
52 result.placeholder = placeholder;
53 return setWrapToString(result, func, bitmask);
56 module.exports = createRecurry;