Files
lodash/_createBaseWrapper.js
John-David Dalton 35cdf6513b Bump to v4.13.0.
2016-05-22 19:35:24 -07:00

30 lines
893 B
JavaScript

import createCtorWrapper from './_createCtorWrapper.js';
import root from './_root.js';
/** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1;
/**
* Creates a function that wraps `func` to invoke it with the optional `this`
* binding of `thisArg`.
*
* @private
* @param {Function} func The function to wrap.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
* for more details.
* @param {*} [thisArg] The `this` binding of `func`.
* @returns {Function} Returns the new wrapped function.
*/
function createBaseWrapper(func, bitmask, thisArg) {
var isBind = bitmask & BIND_FLAG,
Ctor = createCtorWrapper(func);
function wrapper() {
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
return fn.apply(isBind ? thisArg : this, arguments);
}
return wrapper;
}
export default createBaseWrapper;