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.
async-eventemitter
Advanced tools
Just like EventEmitter, but with support for callbacks and interuption of the listener-chain
Readme
An EventEmitter that supports serial execution of asynchronous event listeners. It also supports event listeners without callbacks (synchronous), as well as interrupting the call-chain (similar to the DOM's e.stopPropagation()).
var AsyncEventEmitter = require('async-eventemitter');
var events = new AsyncEventEmitter();
events.on('test', function (e, next) {
// The next event listener will wait til this is done
setTimeout(next, 1000);
});
events
.on('test', function (e) {
// This is a synchronous event listener (note the lack of a second
// callback argument)
console.log(e);
// { data: 'data' }
})
.on('test', function (e, next) {
// Even if you're not truly asynchronous you can use next() to stop propagation
next(new Error('You shall not pass'));
});
events.emit('test', { data: 'data' }, function (err) {
// This is run after all of the event listeners are done
console.log(err);
// [Error: You shall not pass]
});
More examples are found in the test
-folder.
The API and behavior of AsyncEventEmitter is as far as possible and meaningful identical to that of the native EventEmitter. However there are some important differences which should be noted.
eg emit(data)
) must always be zero or
one argument, and can not be a function.function(e, next){}
)..emit()
will
be executed before any event listeners.For addListener() on() once() removeListener() removeAllListeners() setMaxListeners() listeners()
see the EventEmitter docs,
nothing new here.
emit(event, [data], [callback])
Executes all listeners for the event in order with the supplied data argument. The optional callback is called when all of the listeners are done.
.first(event, new)
Adds a listener to the beginning of the listeners array for the specified event.
.at(event, index, listener)
Adds a listener at the specified index in the listeners array for the specified event.
.before(event, target, listener)
Adds a listener before the target listener in the listeners array for the specified event.
.after(event, target, listener)
Adds a listener after the target listener in the listeners array for the specified event.
The MIT License (MIT)
Copyright © 2013 Andreas Hultgren
FAQs
Just like EventEmitter, but with support for callbacks and interuption of the listener-chain
The npm package async-eventemitter receives a total of 168,133 weekly downloads. As such, async-eventemitter popularity was classified as popular.
We found that async-eventemitter 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.