You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

optimize-cb.js 517B

1234567891011
  1. module.exports = (func, context, argCount) => {
  2. if (context === void 0) return func;
  3. switch (argCount == null ? 3 : argCount) {
  4. case 1: return value => func.call(context, value);
  5. // The 2-argument case is omitted because we’re not using it.
  6. case 3: return (value, index, collection) => func.call(context, value, index, collection);
  7. case 4: return (accumulator, value, index, collection) => func.call(context, accumulator, value, index, collection);
  8. }
  9. return (...args) => func.apply(context, args);
  10. };