File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -151,27 +151,28 @@ Example:
151
151
.then(...)
152
152
153
153
<a name =" whilst " />
154
- ### whilst(fn, test ), doWhilst(test, fn )
154
+ ### whilst(test, fn ), doWhilst(fn, test )
155
155
156
156
While the synchronous function ` test() ` returns true, ` whilst ` will continuously execute ` fn() ` . ` fn() ` should return
157
157
a Promise. ` whilst ` will resolve to the same value as the final call to ` fn() ` . If ` fn() ` or ` test() ` throw an error,
158
158
then ` whilst() ` will reject immediately.
159
159
160
160
` doWhilst() ` is similar to ` whilst() ` , but ` whilst() ` might execute ` fn() ` zero times if ` test() ` returns false on the
161
161
first run, where ` doWhilst() ` is guaranteed to call ` fn() ` at least once. Note that the parameters are reversed
162
- between ` whilst() ` and ` doWhilst() ` .
162
+ between ` whilst() ` and ` doWhilst() ` to reflect the fact that one is "while /test/ do /fn/", and the other is "do /fn/
163
+ while /test/" (and to preserver API compatibility with [ async] ( https://github.com/caolan/async#whilst ) ).
163
164
164
165
Example:
165
166
166
167
var count = 0;
167
168
promiseTools.whilst(
169
+ () => count > 10,
168
170
function() {
169
171
count++;
170
172
return Promise.resolve(count);
171
- },
172
- function() {return count > 10;}
173
+ }
173
174
)
174
- .then(function( result) {
175
+ .then(result => {
175
176
// result will be 10 here.
176
177
});
177
178
You can’t perform that action at this time.
0 commit comments