example.js 221 B

1234567891011121314
  1. var throttle = require('./');
  2. function onprogress(n) {
  3. console.log('progress %s%', n);
  4. }
  5. onprogress = throttle(onprogress, 500);
  6. var n = 0;
  7. setInterval(function(){
  8. if (n >= 100) return;
  9. onprogress(n++);
  10. }, 50);