Security News
Internet Archive Hacked, 31 Million Record Compromised
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
@ungap/promise-all-settled
Advanced tools
The @ungap/promise-all-settled npm package is a polyfill for the Promise.allSettled method, which is a part of the ECMAScript 2020 specification. This method returns a promise that resolves after all of the given promises have either fulfilled or rejected, with an array of objects that each describe the outcome of each promise.
Polyfill for Promise.allSettled
This code demonstrates how to use the @ungap/promise-all-settled package to polyfill the Promise.allSettled method. It shows an array of promises, some of which resolve and one that rejects. Promise.allSettled is used to handle all the promises, and the results are logged to the console.
require('@ungap/promise-all-settled');
const promises = [
Promise.resolve(33),
new Promise(resolve => setTimeout(() => resolve(66), 0)),
99,
Promise.reject(new Error('an error'))
];
Promise.allSettled(promises).then(results => console.log(results));
This package provides a shim for the Promise.allSettled method. It offers similar functionality to @ungap/promise-all-settled, allowing users to wait for all promises to settle. The main difference is that it may have different polyfill implementations and support.
Bluebird is a fully-featured promise library with a variety of powerful methods for handling asynchronous operations. It includes its own version of allSettled, called 'reflect', which can be used to achieve similar results. Bluebird is more heavyweight compared to @ungap/promise-all-settled, which serves a single polyfill purpose.
Q is another well-known promise library that provides a method called 'allSettled' for similar functionality. It is a more comprehensive promise management library, so it includes many additional features beyond what @ungap/promise-all-settled offers.
A cross platform Promise.allSettled polyfill.
import allSettled from '@ungap/promise-all-settled'
const allSettled = require('@ungap/promise-all-settled')
const allSettled = require("@ungap/promise-all-settled");
// use it via call
allSettled.call(Promise, []);
// or bind it:
const $settled = allSettled.bind(Promise);
// or put it in the Promise class
if (!Promise.allSettled)
Promise.allSettled = allSettled;
FAQs
A cross platform Promise.allSettled polyfill
The npm package @ungap/promise-all-settled receives a total of 1,365,083 weekly downloads. As such, @ungap/promise-all-settled popularity was classified as popular.
We found that @ungap/promise-all-settled demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
Security News
TC39 is meeting in Tokyo this week and they have approved nearly a dozen proposals to advance to the next stages.
Security News
Our threat research team breaks down two malicious npm packages designed to exploit developer trust, steal your data, and destroy data on your machine.