Skip to content

Commit

Permalink
Q.resolve and Q.when to Q, where possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Jul 17, 2013
1 parent 0e5d134 commit 0d6c12f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ functions, you'll want something like this:
```javascript
var funcs = [foo, bar, baz, qux];

var result = Q.resolve(initialVal);
var result = Q(initialVal);
funcs.forEach(function (f) {
result = result.then(f);
});
Expand All @@ -333,7 +333,7 @@ You can make this slightly more compact using `reduce`:
```javascript
return funcs.reduce(function (soFar, f) {
return soFar.then(f);
}, Q.resolve(initialVal));
}, Q(initialVal));
```

Or, you could use th ultra-compact version:
Expand Down Expand Up @@ -518,7 +518,7 @@ This is a simplified implementation of ``Q.timeout``
function timeout(promise, ms) {
var deferred = Q.defer();
Q.when(promise, deferred.resolve);
Q.when(delay(ms), function () {
delay(ms).then(function () {
deferred.reject(new Error("Timed out"));
});
return deferred.promise;
Expand Down Expand Up @@ -617,7 +617,7 @@ Most libraries only provide a partially functional ``then`` method.
This thankfully is all we need to turn them into vibrant Q promises.

```javascript
return Q.when($.ajax(...))
return Q($.ajax(...))
.then(function () {
});
```
Expand Down

0 comments on commit 0d6c12f

Please sign in to comment.