bind.js 544 B

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