Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / internal / createBindWrapper.js
1 var createCtorWrapper = require('./createCtorWrapper');
2
3 /**
4  * Creates a function that wraps `func` and invokes it with the `this`
5  * binding of `thisArg`.
6  *
7  * @private
8  * @param {Function} func The function to bind.
9  * @param {*} [thisArg] The `this` binding of `func`.
10  * @returns {Function} Returns the new bound function.
11  */
12 function createBindWrapper(func, thisArg) {
13   var Ctor = createCtorWrapper(func);
14
15   function wrapper() {
16     var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func;
17     return fn.apply(thisArg, arguments);
18   }
19   return wrapper;
20 }
21
22 module.exports = createBindWrapper;