This package has been deprecated

Author message:

I am not planning on updating this package, and I have deleted its repository from GitHub. Use promise.allsettled instead (https://www.npmjs.com/package/promise.allsettled).

@tmurphree/promise-all-settled-polyfill

1.0.1 • Public • Published

promise-all-settled-polyfill

Implementation of Promise.allSettled so I can use it before it goes GA.

Yes, this is a redundant repo. See here for one example of another copy. But I wanted to write one as well. I wanted something simple.

The main differnce between my implementation and the proposed native implementation is that my implementation only takes an array, not any iterable. I did this because:

  1. I needed it to work in a short time.
  2. How hard is it to transform an iterable to an array?
  3. This is a polyfill for a feature that's coming soon, so there's no value in making it super flexible.

Installation

npm intsall --save --save-exact @tmurphree/promise-all-settled-polyfill

Usage

Use as you would any other function that returns a promise.

The function name is allSettledPolyfill.

It returns a Promise that resolves to array of objects and rejects to error on bad input.

Output when it [{ status: 'fulfilled', value: 'some-value' }, { status: 'rejected', reason: }]

const axios = require('axios');
const { allSettledPolyfill } = require('@tmurphree/promise-all-settled-polyfill');


allSettledPolyfill([axios.get('http://foo.com'), axios.get('http://bar.com')])
  .then((allResults) => {
    console.log(allResults);
    // something like
    // [{ status: 'fulfilled', value: <the value from the API> }, { status: 'rejected', reason: <the error from the API> }]
  }))
  .catch(console.error);

Package Sidebar

Install

npm i @tmurphree/promise-all-settled-polyfill

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

9.68 kB

Total Files

7

Last publish

Collaborators

  • tmurphree