summaryrefslogtreecommitdiff
path: root/lib/iterator.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/iterator.js')
-rw-r--r--lib/iterator.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/iterator.js b/lib/iterator.js
new file mode 100644
index 0000000..568171a
--- /dev/null
+++ b/lib/iterator.js
@@ -0,0 +1,17 @@
+'use strict';
+
+export default function(tasks) {
+ function makeCallback(index) {
+ function fn() {
+ if (tasks.length) {
+ tasks[index].apply(null, arguments);
+ }
+ return fn.next();
+ }
+ fn.next = function() {
+ return (index < tasks.length - 1) ? makeCallback(index + 1) : null;
+ };
+ return fn;
+ }
+ return makeCallback(0);
+}