![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.
wildemitter
Advanced tools
A super lightweight EventEmitter similar to what comes in Node.js, but with a support for wildcard events '*'
#WildEmitter
##What is it? A super lightweight EventEmitter similar to what comes in Node.js, but with a few specific differences:
emitter.on('*', doSomething)
or emitter.on('myNamespace*', doSomething)
This is largely based on the emitter in @visionmedia's UIKit. So, much props there. I just wanted it as a standalone on npm and with support for *
handlers.
##How do I use it?
You can use it to add event capabilities to other objects you build like so:
var Emitter = require('./wildemitter');
// the example object we're making
function Fruit(name) {
this.name = name;
// call emitter with this context
Emitter.call(this);
}
// inherit from Emitter
Fruit.prototype = new Emitter;
// a function that emits an events when called
Fruit.prototype.test = function () {
this.emit('test', this.name);
};
// set up some test fruits
var apple = new Fruit('apple');
apple.on('*', function () {
console.log('"*" handler called', arguments);
});
apple.on('te*', function () {
console.log('"te*" handler called', arguments);
});
apple.on('test', function () {
console.log('"test" handler called', arguments);
});
// calling the method that emits events.
apple.test();
// it should write the following the log:
/*
"test" handler called { '0': 'apple' }
"*" handler called { '0': 'test', '1': 'apple' }
"te*" handler called { '0': 'test', '1': 'apple' }
*/
// this will remove any handlers explicitly listening for 'test' events.
apple.off('test');
// calling our method again would this time only call the two wildcard handlers
// producing the following output
/*
"*" handler called { '0': 'test', '1': 'apple' }
"te*" handler called { '0': 'test', '1': 'apple' }
*/
##License MIT
If you like this follow @HenrikJoreteg on twitter.
FAQs
A super lightweight EventEmitter similar to what comes in Node.js, but with a support for wildcard events '*' and grouped handlers
The npm package wildemitter receives a total of 26,188 weekly downloads. As such, wildemitter popularity was classified as popular.
We found that wildemitter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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
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.