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

Function createPartialWrapper

lib/web/jshint.js:5105–5128  ·  view source on GitHub ↗

* Creates a function that wraps `func` and invokes it with the optional `this` * binding of `thisArg` and the `partials` prepended to those provided to * the wrapper. * * @private * @param {Function} func The function to partially apply arguments to. * @param {number} b

(func, bitmask, thisArg, partials)

Source from the content-addressed store, hash-verified

5103 * @returns {Function} Returns the new bound function.
5104 */
5105 function createPartialWrapper(func, bitmask, thisArg, partials) {
5106 var isBind = bitmask & BIND_FLAG,
5107 Ctor = createCtorWrapper(func);
5108
5109 function wrapper() {
5110 // Avoid `arguments` object use disqualifying optimizations by
5111 // converting it to an array before providing it `func`.
5112 var argsIndex = -1,
5113 argsLength = arguments.length,
5114 leftIndex = -1,
5115 leftLength = partials.length,
5116 args = Array(argsLength + leftLength);
5117
5118 while (++leftIndex < leftLength) {
5119 args[leftIndex] = partials[leftIndex];
5120 }
5121 while (argsLength--) {
5122 args[leftIndex++] = arguments[++argsIndex];
5123 }
5124 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5125 return fn.apply(isBind ? thisArg : this, args);
5126 }
5127 return wrapper;
5128 }
5129
5130 /**
5131 * Creates a `_.sortedIndex` or `_.sortedLastIndex` function.

Callers

nothing calls this directly

Calls 1

createCtorWrapperFunction · 0.85

Tested by

no test coverage detected