Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / lodash / internal / createPartialWrapper.js
1 var createCtorWrapper = require('./createCtorWrapper');
2
3 /** Used to compose bitmasks for wrapper metadata. */
4 var BIND_FLAG = 1;
5
6 /**
7  * Creates a function that wraps `func` and invokes it with the optional `this`
8  * binding of `thisArg` and the `partials` prepended to those provided to
9  * the wrapper.
10  *
11  * @private
12  * @param {Function} func The function to partially apply arguments to.
13  * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details.
14  * @param {*} thisArg The `this` binding of `func`.
15  * @param {Array} partials The arguments to prepend to those provided to the new function.
16  * @returns {Function} Returns the new bound function.
17  */
18 function createPartialWrapper(func, bitmask, thisArg, partials) {
19   var isBind = bitmask & BIND_FLAG,
20       Ctor = createCtorWrapper(func);
21
22   function wrapper() {
23     // Avoid `arguments` object use disqualifying optimizations by
24     // converting it to an array before providing it `func`.
25     var argsIndex = -1,
26         argsLength = arguments.length,
27         leftIndex = -1,
28         leftLength = partials.length,
29         args = Array(leftLength + argsLength);
30
31     while (++leftIndex < leftLength) {
32       args[leftIndex] = partials[leftIndex];
33     }
34     while (argsLength--) {
35       args[leftIndex++] = arguments[++argsIndex];
36     }
37     var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func;
38     return fn.apply(isBind ? thisArg : this, args);
39   }
40   return wrapper;
41 }
42
43 module.exports = createPartialWrapper;