at-every-turn

3.0.1 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i at-every-turn

Weekly Downloads

0

Version

3.0.1

License

ISC

Last publish

Collaborators

  • elimydlarz