
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
@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,355,694 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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.