blob: feaec00d44c67a71cbb4c3978f21a5a9808218ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
'use strict';
import noop from 'lodash/noop';
import rest from 'lodash/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);
}
|