Files
lodash/internal/createBindWrapper.js
John-David Dalton 5379c1996b Bump to v3.0.0.
2015-01-25 13:44:01 -08:00

22 lines
573 B
JavaScript

import createCtorWrapper from './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() {
return (this instanceof wrapper ? Ctor : func).apply(thisArg, arguments);
}
return wrapper;
}
export default createBindWrapper;