Files
lodash/internal/createBindWrapper.js
John-David Dalton f9606b394c Bump to v3.0.0.
2015-02-04 00:38:56 -08:00

22 lines
578 B
JavaScript

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() {
return (this instanceof wrapper ? Ctor : func).apply(thisArg, arguments);
}
return wrapper;
}
module.exports = createBindWrapper;