summaryrefslogtreecommitdiff
path: root/build-es/whilst.js
diff options
context:
space:
mode:
Diffstat (limited to 'build-es/whilst.js')
-rw-r--r--build-es/whilst.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/build-es/whilst.js b/build-es/whilst.js
new file mode 100644
index 0000000..2f5c2ef
--- /dev/null
+++ b/build-es/whilst.js
@@ -0,0 +1,15 @@
+'use strict';
+
+import noop from 'lodash-es/noop';
+import rest from 'lodash-es/rest';
+
+export default function whilst(test, iterator, cb) {
+ cb = cb || noop;
+ if (!test()) return cb(null);
+ var next = rest(function(err, args) {
+ if (err) return cb(err);
+ if (test.apply(this, args)) return iterator(next);
+ cb.apply(null, [null].concat(args));
+ });
+ iterator(next);
+}