Skip to content

elimydlarz/at-every-turn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

At Every Turn

Do something at every step in your promise chain.

Installation

npm install --save at-every-turn

Usage

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
2

All 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.

About

Do something at every step in your promise chain

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published