Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
`Promise#finally()` ponyfill - Invoked when the promise is settled regardless of outcome
The p-finally npm package is designed to allow you to attach a handler that will be called when a promise is settled (either fulfilled or rejected). This is useful for running cleanup code or finalizing operations, regardless of the promise's outcome.
Attaching a finally handler to a promise
This feature allows you to execute code after a promise has been settled, regardless of whether it was fulfilled or rejected. It's particularly useful for cleanup operations.
const pFinally = require('p-finally');
const promise = new Promise((resolve, reject) => {
// Some asynchronous operation
});
pFinally(promise, () => {
// Code to run on promise settlement
});
Bluebird is a comprehensive promise library that includes a .finally() method among its wide array of features. Compared to p-finally, Bluebird offers a much broader set of promise-related utilities, but it's also larger in size, which might be an overkill for projects only needing a finally functionality.
Q is another promise library that supports a .finally() method. Similar to Bluebird, Q provides a wide range of promise manipulation capabilities. It's more feature-rich than p-finally but also larger, making p-finally a lightweight alternative if the finally functionality is the main requirement.
Promise#finally()
ponyfill - Invoked when the promise is settled regardless of outcome
Useful for cleanup.
$ npm install p-finally
import pFinally from 'p-finally';
const directory = createTempDirectory();
await pFinally(write(directory), () => {
cleanup(directory);
});
Returns a Promise
.
Type: Function
Note: Throwing or returning a rejected promise will reject promise
with the rejection reason.
FAQs
`Promise#finally()` ponyfill - Invoked when the promise is settled regardless of outcome
The npm package p-finally receives a total of 9,005,282 weekly downloads. As such, p-finally popularity was classified as popular.
We found that p-finally 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.