Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
p-finally
Advanced tools
Package description
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.
Readme
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 14,809,561 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.