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

eventemitter3

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eventemitter3 - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

.travis.yml

79

index.js

@@ -43,5 +43,6 @@ 'use strict';

if (!this._events || !this._events[event]) return [];
if (this._events[event].fn) return [this._events[event].fn];
for (var i = 0, l = this._events[event].length, ee = []; i < l; i++) {
ee.push(this._events[event][i].fn);
for (var i = 0, l = this._events[event].length, ee = new Array(l); i < l; i++) {
ee[i] = this._events[event][i].fn;
}

@@ -63,18 +64,16 @@

var listeners = this._events[event]
, length = listeners.length
, len = arguments.length
, ee = listeners[0]
, args
, i, j;
, i;
if (1 === length) {
if (ee.once) this.removeListener(event, ee.fn, true);
if ('function' === typeof listeners.fn) {
if (listeners.once) this.removeListener(event, listeners.fn, true);
switch (len) {
case 1: return ee.fn.call(ee.context), true;
case 2: return ee.fn.call(ee.context, a1), true;
case 3: return ee.fn.call(ee.context, a1, a2), true;
case 4: return ee.fn.call(ee.context, a1, a2, a3), true;
case 5: return ee.fn.call(ee.context, a1, a2, a3, a4), true;
case 6: return ee.fn.call(ee.context, a1, a2, a3, a4, a5), true;
case 1: return listeners.fn.call(listeners.context), true;
case 2: return listeners.fn.call(listeners.context, a1), true;
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
}

@@ -86,4 +85,7 @@

ee.fn.apply(ee.context, args);
listeners.fn.apply(listeners.context, args);
} else {
var length = listeners.length
, j;
for (i = 0; i < length; i++) {

@@ -118,5 +120,12 @@ if (listeners[i].once) this.removeListener(event, listeners[i].fn, true);

EventEmitter.prototype.on = function on(event, fn, context) {
var listener = new EE(fn, context || this);
if (!this._events) this._events = {};
if (!this._events[event]) this._events[event] = [];
this._events[event].push(new EE( fn, context || this ));
if (!this._events[event]) this._events[event] = listener;
else {
if (!this._events[event].fn) this._events[event].push(listener);
else this._events[event] = [
this._events[event], listener
];
}

@@ -135,5 +144,12 @@ return this;

EventEmitter.prototype.once = function once(event, fn, context) {
var listener = new EE(fn, context || this, true);
if (!this._events) this._events = {};
if (!this._events[event]) this._events[event] = [];
this._events[event].push(new EE(fn, context || this, true ));
if (!this._events[event]) this._events[event] = listener;
else {
if (!this._events[event].fn) this._events[event].push(listener);
else this._events[event] = [
this._events[event], listener
];
}

@@ -157,6 +173,11 @@ return this;

if (fn) for (var i = 0, length = listeners.length; i < length; i++) {
if (listeners[i].fn !== fn && listeners[i].once !== once) {
events.push(listeners[i]);
if (fn) {
if (listeners.fn && (listeners.fn !== fn || (once && !listeners.once))) {
events.push(listeners);
}
if (!listeners.fn) for (var i = 0, length = listeners.length; i < length; i++) {
if (listeners[i].fn !== fn || (once && !listeners[i].once)) {
events.push(listeners[i]);
}
}
}

@@ -167,4 +188,7 @@

//
if (events.length) this._events[event] = events;
else this._events[event] = null;
if (events.length) {
this._events[event] = events.length === 1 ? events[0] : events;
} else {
delete this._events[event];
}

@@ -183,3 +207,3 @@ return this;

if (event) this._events[event] = null;
if (event) delete this._events[event];
else this._events = {};

@@ -210,4 +234,5 @@

if ('object' === typeof module && module.exports) {
module.exports = EventEmitter;
}
//
// Expose the module.
//
module.exports = EventEmitter;
{
"name": "eventemitter3",
"version": "0.1.5",
"description": "EventEmitter3 focuses on performance while maintaining a Node.js AND browser compatible interface. This the source of the same EventEmitter that is used in Primus.",
"version": "0.1.6",
"description": "EventEmitter3 focuses on performance while maintaining a Node.js AND browser compatible interface.",
"main": "index.js",
"scripts": {
"test": "NODE_ENV=testing ./node_modules/.bin/mocha $(find test -name '*.test.js')"
"test": "mocha --reporter spec --ui bdd test.js",
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- --reporter spec --ui bdd test.js",
"test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- --reporter spec test.js"
},
"repository": {
"type": "git",
"url": "git://github.com/3rd-Eden/EventEmitter3.git"
"url": "git://github.com/primus/EventEmitter3.git"
},

@@ -33,9 +35,10 @@ "keywords": [

"bugs": {
"url": "https://github.com/3rd-Eden/EventEmitter3/issues"
"url": "https://github.com/primus/EventEmitter3/issues"
},
"devDependencies": {
"mocha": "1.18.x",
"pre-commit": "0.0.x",
"chai": "1.9.x"
"assume": "0.0.x",
"istanbul": "0.3.x",
"mocha": "2.0.x",
"pre-commit": "0.0.x"
}
}
# EventEmitter3
[![Version npm](http://img.shields.io/npm/v/eventemitter3.svg?style=flat-square)](http://browsenpm.org/package/eventemitter3)[![Build Status](http://img.shields.io/travis/primus/EventEmitter3/master.svg?style=flat-square)](https://travis-ci.org/primus/EventEmitter3)[![Dependencies](https://img.shields.io/david/primus/EventEmitter3.svg?style=flat-square)](https://david-dm.org/primus/EventEmitter3)[![Coverage Status](http://img.shields.io/coveralls/primus/EventEmitter3/master.svg?style=flat-square)](https://coveralls.io/r/primus/EventEmitter3?branch=master)[![IRC channel](http://img.shields.io/badge/IRC-irc.freenode.net%23primus-00a8ff.svg?style=flat-square)](http://webchat.freenode.net/?channels=primus)
EventEmitter3 is a faster alternative to EventEmitter2 and the built-in

@@ -10,3 +12,3 @@ EventEmitter that ships within Node.js. It removes some features that you might

- That a `newListener` event is emitted when an event is emitted.
- No silly `setMaxListeners`.
- No silly `setMaxListeners`, the function exists, but does nothing.
- No silly `listenerCount` function.. Just do `EventEmitter.listeners(event).length`

@@ -24,4 +26,3 @@

`Array.isArray` stuff is used, it's just plain ol JavaScript that should even
work IE5 if you want to. This module currently serves its use in
[Primus](http://github.com/primus/primus)'s client file.
work IE5 if you want to.

@@ -49,4 +50,4 @@ ## Installation

For API methods see the official Node.js documentation:
For API methods see the official Node.js documentation:
http://nodejs.org/api/events.html

Sorry, the diff of this file is not supported yet

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