1 var createCtor = require('./_createCtor'),
2 root = require('./_root');
4 /** Used to compose bitmasks for function metadata. */
8 * Creates a function that wraps `func` to invoke it with the optional `this`
9 * binding of `thisArg`.
12 * @param {Function} func The function to wrap.
13 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
14 * @param {*} [thisArg] The `this` binding of `func`.
15 * @returns {Function} Returns the new wrapped function.
17 function createBind(func, bitmask, thisArg) {
18 var isBind = bitmask & BIND_FLAG,
19 Ctor = createCtor(func);
22 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
23 return fn.apply(isBind ? thisArg : this, arguments);
28 module.exports = createBind;