OsoianMarcel / promise-all-always

Execute all the promises whether they resolve or reject

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

promise-all-always

Execute all the promises whether they resolve or reject

Build Status npm version license

Deprecated library

An alternative native solution for this library is Promise.allSettled.

Install

// Yarn
yarn add promise-all-always
// NPM
npm install promise-all-always

Example

const promiseAllAlways = require('promise-all-always');

// Even if second promise is rejected, the execution will continue
// Use "result" property to receive promise result
// Use "isResolved" property to check if the promise is resolved or rejected
promiseAllAlways([
	Promise.resolve(1),
	Promise.reject(0),
	Promise.resolve('done')
]).then(values => {
	for (let value of values) {
		console.log(
			`Result: ${value.result}`,
			'\t',
			`Promise is ${value.isResolved ? 'resolved' : 'rejected'}`
		);
	}
});

// Return raw values (no object)
promiseAllAlways([Promise.resolve(1), Promise.reject(0), Promise.resolve('done')], {rawResult: true})
	.then(values => console.log('Raw result', values));

For more examples check examples folder.

Testing

// Yarn
$ yarn test
// NPM
$ npm test

Contribute

Contributions to the package are always welcome!

License

All contents of this package are licensed under the MIT license.

About

Execute all the promises whether they resolve or reject

License:MIT License


Languages

Language:JavaScript 100.0%