3.0.1 • Published 9 years ago
at-every-turn v3.0.1
At Every Turn
Do something at every step in your promise chain.
Installation
npm install --save at-every-turnUsage
Pass a function and an initial promise to atEveryTurn. The function will be executed against the result of each promise in the ensuing promise chain - including the initial promise.
For example, executing this code:
const atEveryTurn = require('at-every-turn');
atEveryTurn(console.log, Promise.resolve(0))
.then((x) => x + 1)
.then((x) => x + 1);Will produce this console output:
0
1
2All promise behaviour is handled, including: catch, the use of then with onFulfilled and onRejected params, rejection of a then and rejection of the initial promise.