![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
emitter-listener
Advanced tools
shimmer
does a bunch of the work necessary to wrap other methods in
a wrapper you provide:
var EventEmitter = require('events').EventEmitter;
var wrapEmitter = require('emitter-listener');
var ee = new EventEmitter();
var id = 0;
wrapEmitter(
ee,
function mark(listener) {
listener.id = id++;
},
function prepare(listener) {
console.log('listener id is %d', listener.id);
}
);
There are times when it's necessary to monkeypatch default behavior in JavaScript and Node. However, changing the behavior of the runtime on the fly is rarely a good idea, and you should be using this module because you need to, not because it seems like fun.
Wrap an EventEmitter's event listeners. Each listener will be passed to
mark
when it is registered with .addListener()
or .on()
, and then
each listener is passed to prepare
to be wrapped before it's called
by the .emit()
call. wrapListener
deals with the single listener
vs array of listeners logic, and also ensures that edge cases like
.removeListener()
being called from within an .emit()
for the same
event type is handled properly.
The wrapped EE can be restored to its pristine state by using emitter.__unwrap(), but this should only be used if you really know what you're doing.
FAQs
(Meta)observability for EventEmitters.
The npm package emitter-listener receives a total of 1,763,060 weekly downloads. As such, emitter-listener popularity was classified as popular.
We found that emitter-listener 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.