Skip to content

Commit e22e04a

Browse files
committed
Update README.md
1 parent 1131104 commit e22e04a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,27 +151,28 @@ Example:
151151
.then(...)
152152

153153
<a name="whilst"/>
154-
### whilst(fn, test), doWhilst(test, fn)
154+
### whilst(test, fn), doWhilst(fn, test)
155155

156156
While the synchronous function `test()` returns true, `whilst` will continuously execute `fn()`. `fn()` should return
157157
a Promise. `whilst` will resolve to the same value as the final call to `fn()`. If `fn()` or `test()` throw an error,
158158
then `whilst()` will reject immediately.
159159

160160
`doWhilst()` is similar to `whilst()`, but `whilst()` might execute `fn()` zero times if `test()` returns false on the
161161
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)).
163164

164165
Example:
165166

166167
var count = 0;
167168
promiseTools.whilst(
169+
() => count > 10,
168170
function() {
169171
count++;
170172
return Promise.resolve(count);
171-
},
172-
function() {return count > 10;}
173+
}
173174
)
174-
.then(function(result) {
175+
.then(result => {
175176
// result will be 10 here.
176177
});
177178

0 commit comments

Comments
 (0)