bind.js 528 B

12345678910111213
  1. import restArguments from './restArguments.js';
  2. import isFunction from './isFunction.js';
  3. import executeBound from './_executeBound.js';
  4. // Create a function bound to a given object (assigning `this`, and arguments,
  5. // optionally).
  6. export default restArguments(function(func, context, args) {
  7. if (!isFunction(func)) throw new TypeError('Bind must be called on a function');
  8. var bound = restArguments(function(callArgs) {
  9. return executeBound(func, bound, context, this, args.concat(callArgs));
  10. });
  11. return bound;
  12. });