
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
async-event
Advanced tools
Simple async event handling and interception.
npm install --save async-event
Requires a promise implementation to be global
var AsyncEvent = require('async-event');
var user = { id: 123 };
var event = new AsyncEvent(user);
myPubSub.publish('my-event', event);
event
.then(function() {
console.log('Passed async validation!');
})
.catch(function() {
console.log('Failed async validation :(');
});
// Some other listener
myPubSub.subscribe('my-event', function(event) {
event.intercept(function(user) {
return fetch('/user/123/validate', {
method: 'POST',
body: JSON.stringify(user)
});
})
});
AsyncEvent
The constructor.
Param | Type | Description |
---|---|---|
value | any | The initial value |
promise | Promise | An optional starting promise |
void
A function that can perform a sync or async task. Handlers are executed in serial order.
Param | Type | Description |
---|---|---|
handler | Function | The intercept function |
any
Gets the initial value the event initialized with.
Promise
Delegates to the internal Promise. Subscribes to the chain at that point in time. This will not add to the chain. This can be used to perform a task that you would want to happen in parallel.
Param | Type | Description |
---|---|---|
fn | Function | The promise function |
Promise
Same as then
except the catch equivalent.
Param | Type | Description |
---|---|---|
fn | Function | The promise function |
FAQs
Simple event for async tasks
The npm package async-event receives a total of 2 weekly downloads. As such, async-event popularity was classified as not popular.
We found that async-event 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.