diff options
Diffstat (limited to 'deps/npm/node_modules/lodash/internal/createBindWrapper.js')
-rw-r--r-- | deps/npm/node_modules/lodash/internal/createBindWrapper.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/deps/npm/node_modules/lodash/internal/createBindWrapper.js b/deps/npm/node_modules/lodash/internal/createBindWrapper.js new file mode 100644 index 0000000000..54086ee88c --- /dev/null +++ b/deps/npm/node_modules/lodash/internal/createBindWrapper.js @@ -0,0 +1,22 @@ +var createCtorWrapper = require('./createCtorWrapper'); + +/** + * Creates a function that wraps `func` and invokes it with the `this` + * binding of `thisArg`. + * + * @private + * @param {Function} func The function to bind. + * @param {*} [thisArg] The `this` binding of `func`. + * @returns {Function} Returns the new bound function. + */ +function createBindWrapper(func, thisArg) { + var Ctor = createCtorWrapper(func); + + function wrapper() { + var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func; + return fn.apply(thisArg, arguments); + } + return wrapper; +} + +module.exports = createBindWrapper; |