Removed modules/contrib/media module to allow update to the core media module
[yaffs-website] / node_modules / uncss / node_modules / lodash / internal / createCurryWrapper.js
1 var apply = require('./apply'),
2     createCtorWrapper = require('./createCtorWrapper'),
3     createHybridWrapper = require('./createHybridWrapper'),
4     createRecurryWrapper = require('./createRecurryWrapper'),
5     replaceHolders = require('./replaceHolders');
6
7 /**
8  * Creates a function that wraps `func` to enable currying.
9  *
10  * @private
11  * @param {Function} func The function to wrap.
12  * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details.
13  * @param {number} arity The arity of `func`.
14  * @returns {Function} Returns the new wrapped function.
15  */
16 function createCurryWrapper(func, bitmask, arity) {
17   var Ctor = createCtorWrapper(func);
18
19   function wrapper() {
20     var length = arguments.length,
21         index = length,
22         args = Array(length),
23         fn = (this && this !== global && this instanceof wrapper) ? Ctor : func,
24         placeholder = wrapper.placeholder;
25
26     while (index--) {
27       args[index] = arguments[index];
28     }
29     var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
30       ? []
31       : replaceHolders(args, placeholder);
32
33     length -= holders.length;
34     return length < arity
35       ? createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, undefined, args, holders, undefined, undefined, arity - length)
36       : apply(fn, this, args);
37   }
38   return wrapper;
39 }
40
41 module.exports = createCurryWrapper;