Skip to content

Commit

Permalink
Document delay.reject
Browse files Browse the repository at this point in the history
  • Loading branch information
ariporad committed Dec 24, 2015
1 parent 07f43e2 commit 131f575
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ async () => {
// executed 100 milliseconds later
baz();
}();

// Mostly for testing purposes, there is also delay.reject. It takes the value, and rejects it `ms` later.
Promise.resolve('foo')
.then(delay.reject(100))
.then(x => blah()) // This is never executed.
.catch(e => {
// executed 100 milliseconds later
// e === 'foo'
});

// You can also specify the rejection value:
Promise.resolve('foo')
.then(delay.reject(100, 'bar'))
.then(x => blah()) // Never executed.
.catch(e => {
// executed 100 milliseconds later
// e === 'bar'
});
```


Expand Down

0 comments on commit 131f575

Please sign in to comment.