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

emitter-component

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emitter-component - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

2

component.json

@@ -5,4 +5,4 @@ {

"keywords": ["emitter", "events"],
"version": "0.0.5",
"version": "0.0.6",
"scripts": ["index.js"]
}
0.0.6 / 2012-10-08
==================
* add `this._callbacks` initialization to prevent funky gotcha
0.0.5 / 2012-09-07

@@ -3,0 +8,0 @@ ==================

@@ -16,3 +16,2 @@

if (obj) return mixin(obj);
this._callbacks = {};
};

@@ -29,3 +28,2 @@

function mixin(obj) {
obj._callbacks = {};
for (var key in Emitter.prototype) {

@@ -47,2 +45,3 @@ obj[key] = Emitter.prototype[key];

Emitter.prototype.on = function(event, fn){
this._callbacks = this._callbacks || {};
(this._callbacks[event] = this._callbacks[event] || [])

@@ -65,2 +64,3 @@ .push(fn);

var self = this;
this._callbacks = this._callbacks || {};

@@ -88,2 +88,3 @@ function on() {

Emitter.prototype.off = function(event, fn){
this._callbacks = this._callbacks || {};
var callbacks = this._callbacks[event];

@@ -113,2 +114,3 @@ if (!callbacks) return this;

Emitter.prototype.emit = function(event){
this._callbacks = this._callbacks || {};
var args = [].slice.call(arguments, 1)

@@ -136,2 +138,3 @@ , callbacks = this._callbacks[event];

Emitter.prototype.listeners = function(event){
this._callbacks = this._callbacks || {};
return this._callbacks[event] || [];

@@ -138,0 +141,0 @@ };

{
"name": "emitter-component",
"description": "Event emitter",
"version": "0.0.5",
"version": "0.0.6",
"devDependencies": {

@@ -6,0 +6,0 @@ "mocha": "*",

@@ -17,7 +17,26 @@ # Emitter

a "plain" object may become an emitter, or you may
extend an existing prototype:
extend an existing prototype.
As an `Emitter` instance:
```js
var obj = {};
Emitter(obj);
var Emitter = require('emitter');
var emitter = new Emitter;
emitter.emit('something');
```
As a mixin:
```js
var Emitter = require('emitter');
var user = { name: 'tobi' };
Emitter(user);
user.emit('im a user');
```
As a prototype mixin:
```js
var Emitter = require('emitter');
Emitter(User.prototype);

@@ -24,0 +43,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