series.js 502 B

12345678910111213141516171819202122
  1. /**
  2. * Returns a function that will execute a list of functions in sequence
  3. * passing the same arguments to each one. (useful for batch processing
  4. * items during a forEach loop)
  5. */
  6. function series(){
  7. var fns = arguments;
  8. return function(){
  9. var i = 0,
  10. n = fns.length;
  11. while (i < n) {
  12. fns[i].apply(this, arguments);
  13. i += 1;
  14. }
  15. };
  16. }
  17. module.exports = series;