JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 509869
  • Score
    100M100P100Q177428F
  • 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);
    //=> [{value: 'unicorn'}, {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 a value property if the promise fulfilled or reason property if the promise rejected.

input

Type: Iterable<Promise|any>

License

MIT © Sindre Sorhus