function-bind-context.js 457 B

12345678910111213
  1. var uncurryThis = require('../internals/function-uncurry-this');
  2. var aCallable = require('../internals/a-callable');
  3. var NATIVE_BIND = require('../internals/function-bind-native');
  4. var bind = uncurryThis(uncurryThis.bind);
  5. // optional / simple context binding
  6. module.exports = function (fn, that) {
  7. aCallable(fn);
  8. return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) {
  9. return fn.apply(that, arguments);
  10. };
  11. };