_bindCb4.js 520 B

1234567891011121314151617
  1. define(function () {
  2. // In Firefox, `Function.prototype.call` is faster than
  3. // `Function.prototype.apply`. In the optimized variant of
  4. // `bindCb` below, we exploit the fact that no Underscore
  5. // function passes more than four arguments to a callback.
  6. // **NOT general enough for use outside of Underscore.**
  7. function bindCb4(func, context) {
  8. if (context === void 0) return func;
  9. return function(a1, a2, a3, a4) {
  10. return func.call(context, a1, a2, a3, a4);
  11. };
  12. }
  13. return bindCb4;
  14. });