mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Add definition and test for when.iterate
This commit is contained in:
@@ -101,6 +101,21 @@ when.settle<number>([when(1), when(2), when.reject(new Error("Foo"))]).then(desc
|
||||
return descriptors.filter(d => d.state === 'rejected').reduce((r, d) => r + d.value, 0);
|
||||
});
|
||||
|
||||
/* when.iterate(f, predicate, handler, seed) */
|
||||
|
||||
when.iterate(function (x) {
|
||||
return x + 1;
|
||||
}, function (x) {
|
||||
// Stop when x >= 100000000000
|
||||
return x >= 100000000000;
|
||||
}, function (x) {
|
||||
console.log(x);
|
||||
}, 0).done(function (x) {
|
||||
console.log(x === 100000000000);
|
||||
}, function (err) {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
/* when.promise(resolver) */
|
||||
|
||||
promise = when.promise<number>(resolve => resolve(5));
|
||||
|
||||
Reference in New Issue
Block a user