No Description

before.js 300B

123456789101112
  1. // Returns a function that will only be executed up to (but not including) the
  2. // Nth call.
  3. export default function before(times, func) {
  4. var memo;
  5. return function() {
  6. if (--times > 0) {
  7. memo = func.apply(this, arguments);
  8. }
  9. if (times <= 1) func = null;
  10. return memo;
  11. };
  12. }