function-bind-context.js 478 B

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