Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wildemitter

Package Overview
Dependencies
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wildemitter - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

package.json
{
"name": "wildemitter",
"version": "1.0.1",
"version": "1.0.2",
"author": "Henrik Joreteg <henrik@andyet.net>",

@@ -5,0 +5,0 @@ "scripts": {

# WildEmitter - A lightweight event emitter that supports wildcard handlers
## What's an event emitter?
If you've ever listened for a click event in a browser you've used an emitter. But, user interaction isn't the only thing that can trigger an event worth listening to. You can also make other objects capable of emitting events. That's what wildemitter is for. You can extend your objects with it so that you can emit events from them and register handlers on them. This pattern helps you write more re-usable code becaause your objct doen't have to know how it's going to be used. It can simply emit events any time something happens that other code *may* be interested in.
If you've ever listened for a click event in a browser you've used an emitter. But, user interaction isn't the only thing that can trigger an event worth listening to. You can also make other objects capable of emitting events. That's what wildemitter is for. You can extend your objects with it so that you can emit events from them and register handlers on them. This pattern helps you write more re-usable code because your object doen't have to know how it's going to be used. It can simply emit events any time something happens that other code *may* be interested in.

@@ -6,0 +6,0 @@ You'll see this type of pattern a lot in node.js. Where lots of things in the standard libraries inherit from EventEmitter and emit various events to indicate progress, errors, completion, etc.

@@ -65,2 +65,5 @@ function WildEmitter() {

callbacks.splice(i, 1);
if (callbacks.length === 0) {
delete this.callbacks[event];
}
return this;

@@ -67,0 +70,0 @@ };

@@ -94,2 +94,3 @@ var Emitter = require('./wildemitter');

var count, cb1, cb2;
var orange = new Fruit('orange');

@@ -117,4 +118,10 @@ count = 0;

orange.off('test2', cb2);
//ensure callbacks array is removed entirely
test.ok(orange.callbacks.test == null);
test.ok(orange.callbacks.test2 == null);
test.done();
};

@@ -65,2 +65,5 @@ function WildEmitter() {

callbacks.splice(i, 1);
if (callbacks.length === 0) {
delete this.callbacks[event];
}
return this;

@@ -67,0 +70,0 @@ };

@@ -86,2 +86,5 @@ /*

callbacks.splice(i, 1);
if (callbacks.length === 0) {
delete this.callbacks[event];
}
return this;

@@ -88,0 +91,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc