![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
event-cleanup
Advanced tools
Readme
Wrap an EventEmitter for easy listener cleanup
npm install event-cleanup
var wrap = require('event-cleanup')
// wrap an EventEmitter called `emitter`
var wrapper = wrap(emitter)
// wrapper has all of the EventEmitter methods
// and receives all events emitted by `emitter`
wrapper.on(...)
wrapper.once(...)
wrapper.removeListener(...)
...
// when done, remove all listeners on `wrapper`
// (leaving `emitter` untouched)
wrapper.removeAll()
event-cleanup
lets you wrap an EventEmitter
, letting you add/remove listeners to a separate EventEmitter
without polluting the original. When you are done, you can clean up all of the listeners added to the wrapper EventEmitter
.
var wrapper = wrap(emitter)
Creates a wrapper EventEmitter
which receives all events emitted by emitter
.
The returned object has all EventEmitter
methods (e.g. wrapper.on(event, listener)
). Calling wrapper.emit(event, listener)
will only emit the event to the listeners added directly to the wrapper, not the wrapped emitter
.
wrapper.removeAll()
Removes all listeners added directly to wrapper
.
I often found myself in a code pattern where I would temporarily add event listeners to some EventEmitter
, then need to remove them all when done. However, this requires keeping a reference to all listener functions so that they can be removed with removeListener()
, which can be inconvenient. It also makes it possible to accidentally leak listeners if they never got removed.
This module makes this use-case easy: in a function where you add temporary listeners, wrap the EventEmitter
and add the listeners to it, then call removeAll()
when done to ensure all listeners are cleaned up.
FAQs
Wrap an EventEmitter for easy listener cleanup
The npm package event-cleanup receives a total of 23 weekly downloads. As such, event-cleanup popularity was classified as not popular.
We found that event-cleanup 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.