No Description

before.js 354B

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