MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / createHybridWrapper

Function createHybridWrapper

lib/web/jshint.js:4999–5069  ·  view source on GitHub ↗

* Creates a function that wraps `func` and invokes it with optional `this` * binding of, partial application, and currying. * * @private * @param {Function|string} func The function or method name to reference. * @param {number} bitmask The bitmask of flags. See `createWrapp

(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity)

Source from the content-addressed store, hash-verified

4997 * @returns {Function} Returns the new wrapped function.
4998 */
4999 function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
5000 var isAry = bitmask & ARY_FLAG,
5001 isBind = bitmask & BIND_FLAG,
5002 isBindKey = bitmask & BIND_KEY_FLAG,
5003 isCurry = bitmask & CURRY_FLAG,
5004 isCurryBound = bitmask & CURRY_BOUND_FLAG,
5005 isCurryRight = bitmask & CURRY_RIGHT_FLAG;
5006
5007 var Ctor = !isBindKey && createCtorWrapper(func),
5008 key = func;
5009
5010 function wrapper() {
5011 // Avoid `arguments` object use disqualifying optimizations by
5012 // converting it to an array before providing it to other functions.
5013 var length = arguments.length,
5014 index = length,
5015 args = Array(length);
5016
5017 while (index--) {
5018 args[index] = arguments[index];
5019 }
5020 if (partials) {
5021 args = composeArgs(args, partials, holders);
5022 }
5023 if (partialsRight) {
5024 args = composeArgsRight(args, partialsRight, holdersRight);
5025 }
5026 if (isCurry || isCurryRight) {
5027 var placeholder = wrapper.placeholder,
5028 argsHolders = replaceHolders(args, placeholder);
5029
5030 length -= argsHolders.length;
5031 if (length < arity) {
5032 var newArgPos = argPos ? arrayCopy(argPos) : null,
5033 newArity = nativeMax(arity - length, 0),
5034 newsHolders = isCurry ? argsHolders : null,
5035 newHoldersRight = isCurry ? null : argsHolders,
5036 newPartials = isCurry ? args : null,
5037 newPartialsRight = isCurry ? null : args;
5038
5039 bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);
5040 bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);
5041
5042 if (!isCurryBound) {
5043 bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
5044 }
5045 var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity],
5046 result = createHybridWrapper.apply(undefined, newData);
5047
5048 if (isLaziable(func)) {
5049 setData(result, newData);
5050 }
5051 result.placeholder = placeholder;
5052 return result;
5053 }
5054 }
5055 var thisBinding = isBind ? thisArg : this;
5056 if (isBindKey) {

Callers 1

runInContextFunction · 0.85

Calls 1

createCtorWrapperFunction · 0.85

Tested by

no test coverage detected