1 var createCtorWrapper = require('./createCtorWrapper');
3 /** Used to compose bitmasks for wrapper metadata. */
7 * Creates a function that wraps `func` to invoke it with the optional `this`
8 * binding of `thisArg`.
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.
16 function createBaseWrapper(func, bitmask, thisArg) {
17 var isBind = bitmask & BIND_FLAG,
18 Ctor = createCtorWrapper(func);
21 var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func;
22 return fn.apply(isBind ? thisArg : this, arguments);
27 module.exports = createBaseWrapper;