Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
The 'after' npm package is a small utility that helps manage asynchronous operations by executing a callback after a specified number of operations have completed. It is particularly useful for scenarios where you need to wait for multiple asynchronous tasks to finish before proceeding.
Execute callback after multiple asynchronous operations
This feature allows you to specify a callback function that will be executed after a certain number of asynchronous operations have completed. In this example, the callback will be executed after three tasks have finished.
const after = require('after');
const done = after(3, () => {
console.log('All tasks completed');
});
setTimeout(() => {
console.log('Task 1 done');
done();
}, 1000);
setTimeout(() => {
console.log('Task 2 done');
done();
}, 2000);
setTimeout(() => {
console.log('Task 3 done');
done();
}, 3000);
The 'async' package provides a wide range of utilities for working with asynchronous JavaScript, including functions for parallel and series execution, queue management, and more. It is more feature-rich compared to 'after' and can handle more complex asynchronous workflows.
The 'promise' package is a lightweight implementation of Promises/A+ that allows you to work with asynchronous operations in a more modern and flexible way compared to callbacks. It provides methods like 'all' and 'race' to manage multiple promises, making it a more versatile option than 'after'.
The 'bluebird' package is a fully-featured Promise library that offers advanced features like cancellation, iteration methods, and more. It is more powerful and flexible than 'after', making it suitable for complex asynchronous workflows.
Invoke callback after n calls
var after = require("after")
, next = after(3, logItWorks)
next()
next()
next() // it works
function logItWorks() {
console.log("it works!")
}
var after = require("after")
, next = after(3, logError)
next()
next(new Error("oops")) // logs oops
next() // does nothing
function logError(err) {
console.log(err)
}
Older versions of after had iterators and flows in them.
These have been replaced with seperate modules
npm install after
make test
FAQs
after - tiny flow control
The npm package after receives a total of 1,228,481 weekly downloads. As such, after popularity was classified as popular.
We found that after demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.