Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Execute all the promises whether they resolve or reject

License

Notifications You must be signed in to change notification settings

OsoianMarcel/promise-all-always

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.