JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 506994
  • Score
    100M100P100Q177180F
  • License MIT

Settle promises concurrently and get their fulfillment value or rejection reason

Package Exports

  • p-settle

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (p-settle) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

p-settle Build Status

Settle promises concurrently and get their fulfillment value or rejection reason

Install

$ npm install --save p-settle

Usage

const pSettle = require('p-settle');
const promisify = require('pify');
const fs = promisify(require('fs'));

const files = [
    'a.txt',
    'b.txt' // doesn't exist
].map(x => fs.readFile(x, 'utf8'));

pSettle(files).then(result => {
    console.log(result);
    /*
    [{
        isFulfilled: true,
        isRejected: false,
        value: '🦄'
    },
    {
        isFulfilled: false,
        isRejected: true,
        reason: [Error: ENOENT: no such file or directory, open 'b.txt']
    }]
    */
});

API

pSettle(input)

Returns a Promise that is fulfilled when all promises in input are settled.

The fulfilled value is an array of objects with the following properties:

  • isFulfilled
  • isRejected
  • value or reason (Depending on whether the promise fulfilled or rejected)

input

Type: Iterable<Promise|any>

  • p-reflect - Make a promise always fulfill with its actual fulfillment value or rejection reason
  • p-map - Map over promises concurrently
  • More…

License

MIT © Sindre Sorhus