diff options
Diffstat (limited to 'tools/eslint/node_modules/lodash/_createPartialWrapper.js')
-rw-r--r-- | tools/eslint/node_modules/lodash/_createPartialWrapper.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/lodash/_createPartialWrapper.js b/tools/eslint/node_modules/lodash/_createPartialWrapper.js new file mode 100644 index 0000000000..1fc3a9b01e --- /dev/null +++ b/tools/eslint/node_modules/lodash/_createPartialWrapper.js @@ -0,0 +1,43 @@ +var apply = require('./_apply'), + createCtorWrapper = require('./_createCtorWrapper'), + root = require('./_root'); + +/** Used to compose bitmasks for wrapper metadata. */ +var BIND_FLAG = 1; + +/** + * Creates a function that wraps `func` to invoke 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 wrap. + * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} partials The arguments to prepend to those provided to the new function. + * @returns {Function} Returns the new wrapped function. + */ +function createPartialWrapper(func, bitmask, thisArg, partials) { + var isBind = bitmask & BIND_FLAG, + Ctor = createCtorWrapper(func); + + function wrapper() { + var argsIndex = -1, + argsLength = arguments.length, + leftIndex = -1, + leftLength = partials.length, + args = Array(leftLength + argsLength), + fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + + while (++leftIndex < leftLength) { + args[leftIndex] = partials[leftIndex]; + } + while (argsLength--) { + args[leftIndex++] = arguments[++argsIndex]; + } + return apply(fn, isBind ? thisArg : this, args); + } + return wrapper; +} + +module.exports = createPartialWrapper; |