Skip to content
This repository has been archived by the owner. It is now read-only.
Call all promises in an array whether they resolve or reject
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
.gitignore
LICENSE
README.md
index.js
package.json
test.js
yarn.lock

README.md

@ianwalter/promise-complete

Call all promises in an array whether they resolve or reject

Npm page

Archived

I'm archiving this module since this functionality will soon be native to JavaScript when the Promise.allSettled proposal is added. Until then, you can also use the p-settle module from @sindresorhus.

About

This is exactly like Promise.all except that it won't reject and stop promises from being called. Resolve and rejection values are returned in the results array in the same order as the promises were given so you can iterate over the array and check/handle errors after all of the promises have resolved/rejected. promise-complete also accepts a map (Object) and non-promise values as input.

Installation

yarn add @ianwalter/promise-complete

Usage

Promise.complete = require('@ianwalter/promise-complete')

// Output all promise results to a results array:
const results = await Promise.complete([promise1, promise2])

// Log any results that are instances of Error:
results.filter(r => r instanceof Error).forEach(e => console.error(e))

License

Apache 2.0 with Commons Clause - See LICENSE

 

Created by Ian Walter

You can’t perform that action at this time.