Git Product home page Git Product logo

promise-all-always's Introduction

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.

promise-all-always's People

Contributors

osoianmarcel avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

promise-all-always's Issues

Deprecation: Promise.allSettled native implementation with less overhead

In reference to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled, it looks like we're now all set in terms of allSettled making its way into the spec. Would either consider deprecating this package and directing people to use the built-in method without unnecessary overhead or third party bloat, or to specifically check for polyfill and prominently note on the Readme so as not to mislead developers. There are no features in this library that cannot be solved with a simple await and clean .map(e => e.value ?? e.reason) rather than 50+ lines of bloat.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.