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

Function createWrapper

lib/web/jshint.js:5171–5209  ·  view source on GitHub ↗

* Creates a function that either curries or invokes `func` with optional * `this` binding and partially applied arguments. * * @private * @param {Function|string} func The function or method name to reference. * @param {number} bitmask The bitmask of flags. * The bitma

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

Source from the content-addressed store, hash-verified

5169 * @returns {Function} Returns the new wrapped function.
5170 */
5171 function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
5172 var isBindKey = bitmask & BIND_KEY_FLAG;
5173 if (!isBindKey && typeof func != 'function') {
5174 throw new TypeError(FUNC_ERROR_TEXT);
5175 }
5176 var length = partials ? partials.length : 0;
5177 if (!length) {
5178 bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);
5179 partials = holders = null;
5180 }
5181 length -= (holders ? holders.length : 0);
5182 if (bitmask & PARTIAL_RIGHT_FLAG) {
5183 var partialsRight = partials,
5184 holdersRight = holders;
5185
5186 partials = holders = null;
5187 }
5188 var data = isBindKey ? null : getData(func),
5189 newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
5190
5191 if (data) {
5192 mergeData(newData, data);
5193 bitmask = newData[1];
5194 arity = newData[9];
5195 }
5196 newData[9] = arity == null
5197 ? (isBindKey ? 0 : func.length)
5198 : (nativeMax(arity - length, 0) || 0);
5199
5200 if (bitmask == BIND_FLAG) {
5201 var result = createBindWrapper(newData[0], newData[2]);
5202 } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) {
5203 result = createPartialWrapper.apply(undefined, newData);
5204 } else {
5205 result = createHybridWrapper.apply(undefined, newData);
5206 }
5207 var setter = data ? baseSetData : setData;
5208 return setter(result, newData);
5209 }
5210
5211 /**
5212 * A specialized version of `baseIsEqualDeep` for arrays with support for

Callers 5

curryFuncFunction · 0.85
createPartialFunction · 0.85
aryFunction · 0.85
runInContextFunction · 0.85
wrapFunction · 0.85

Calls 3

mergeDataFunction · 0.85
createBindWrapperFunction · 0.85
applyMethod · 0.65

Tested by

no test coverage detected