Removed modules/contrib/media module to allow update to the core media module
[yaffs-website] / node_modules / uncss / node_modules / lodash / internal / createBaseWrapper.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` to invoke it with the optional `this`
8  * binding of `thisArg`.
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 {*} [thisArg] The `this` binding of `func`.
14  * @returns {Function} Returns the new wrapped function.
15  */
16 function createBaseWrapper(func, bitmask, thisArg) {
17   var isBind = bitmask & BIND_FLAG,
18       Ctor = createCtorWrapper(func);
19
20   function wrapper() {
21     var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func;
22     return fn.apply(isBind ? thisArg : this, arguments);
23   }
24   return wrapper;
25 }
26
27 module.exports = createBaseWrapper;