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

event-emitter

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-emitter - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

lib/_id.js

61

benchmark/many-on.js

@@ -6,7 +6,13 @@ 'use strict';

//
// $ npm install bench eventemitter2 signals
// $ node benchmark/single-on.js
// $ npm install eventemitter2 signals
// $ node benchmark/many-on.js
var ee, native, ee2, signals;
var forEach = require('es5-ext/lib/Object/for-each')
, pad = require('es5-ext/lib/String/prototype/pad')
, now = Date.now
, time, total, count = 1000000, i, data = {}
, ee, native, ee2, signals, a = {}, b = {};
ee = (function () {

@@ -44,19 +50,36 @@ var ee = require('../lib/core')();

var a = {}, b = {};
console.log("Emit for 3 listeners", "x" + count + ":\n");
exports.compare = {
"event-emitter (this implementation)": function () {
ee.emit('test', a, b);
},
"EventEmitter (Node's native)": function () {
native.emit('test', a, b);
},
"EventEmitter2": function () {
ee2.emit('test', a, b);
},
"Signals": function () {
signals.test.dispatch(a, b);
}
};
i = count;
time = now();
while (i--) {
ee.emit('test', a, b);
}
data["event-emitter (this implementation)"] = now() - time;
require('bench').runMain();
i = count;
time = now();
while (i--) {
native.emit('test', a, b);
}
data["EventEmitter (Node.js native)"] = now() - time;
i = count;
time = now();
while (i--) {
ee2.emit('test', a, b);
}
data["EventEmitter2"] = now() - time;
i = count;
time = now();
while (i--) {
signals.test.dispatch(a, b);
}
data["Signals"] = now() - time;
forEach(data, function (value, name, obj, index) {
console.log(index + 1 + ":", pad.call(value, " ", 5), name);
}, null, function (a, b) {
return this[a] - this[b];
});

@@ -6,7 +6,13 @@ 'use strict';

//
// $ npm install bench eventemitter2 signals
// $ npm install eventemitter2 signals
// $ node benchmark/single-on.js
var ee, native, ee2, signals;
var forEach = require('es5-ext/lib/Object/for-each')
, pad = require('es5-ext/lib/String/prototype/pad')
, now = Date.now
, time, total, count = 1000000, i, data = {}
, ee, native, ee2, signals, a = {}, b = {};
ee = (function () {

@@ -34,19 +40,36 @@ var ee = require('../lib/core');

var a = {}, b = {};
console.log("Emit for single listener", "x" + count + ":\n");
exports.compare = {
"event-emitter (this)": function () {
ee.emit('test', a, b);
},
"EventEmitter (Node's native)": function () {
native.emit('test', a, b);
},
"EventEmitter2": function () {
ee2.emit('test', a, b);
},
"Signals": function () {
signals.test.dispatch(a, b);
}
};
i = count;
time = now();
while (i--) {
ee.emit('test', a, b);
}
data["event-emitter (this implementation)"] = now() - time;
require('bench').runMain();
i = count;
time = now();
while (i--) {
native.emit('test', a, b);
}
data["EventEmitter (Node.js native)"] = now() - time;
i = count;
time = now();
while (i--) {
ee2.emit('test', a, b);
}
data["EventEmitter2"] = now() - time;
i = count;
time = now();
while (i--) {
signals.test.dispatch(a, b);
}
data["Signals"] = now() - time;
forEach(data, function (value, name, obj, index) {
console.log(index + 1 + ":", pad.call(value, " ", 5), name);
}, null, function (a, b) {
return this[a] - this[b];
});
'use strict';
var value = require('es5-ext/lib/Object/valid-value')
, id = '- ee v0.2 -';
, id = require('./_id');

@@ -6,0 +6,0 @@ module.exports = function (emitter) {

'use strict';
var copy = require('es5-ext/lib/Array/prototype/copy')
, d = require('es5-ext/lib/Object/descriptor')
, callable = require('es5-ext/lib/Object/valid-callable')
var d = require('es5-ext/lib/Object/descriptor')
, callable = require('es5-ext/lib/Object/valid-callable')
, id = require('./_id')

@@ -12,8 +12,5 @@ , apply = Function.prototype.apply, call = Function.prototype.call

, on, once, off, emit
, id, colId, onceTag
, methods, descriptors, base;
, colId, onceTag, methods, descriptors, base;
id = '- ee v0.2 -';
colId = '- ee listeners v0.2 -';
onceTag = '\u0001once';
colId = id + 'l_';

@@ -35,4 +32,3 @@ on = function (type, listener) {

} else {
(data[type] = [data[type], listener]).copy = copy;
data[type][colId] = true;
(data[type] = [data[type], listener])[colId] = true;
}

@@ -109,3 +105,3 @@

listeners = listeners.copy();
listeners = listeners.slice();
for (i = 0; (listener = listeners[i]); ++i) {

@@ -112,0 +108,0 @@ apply.call(listener, this, args);

{
"name": "event-emitter",
"version": "0.2.0",
"description": "Basic event emitter for Node.js and browser",
"version": "0.2.1",
"description": "Cross-environment event emitter",
"keywords": [

@@ -6,0 +6,0 @@ "event",

@@ -38,3 +38,3 @@ # EventEmitter – Cross-environment event emitter solution for JavaScript

### allOff
### allOff(obj)

@@ -48,3 +48,3 @@ Remove all listeners

### pipe
### pipe(emitter1, emitter2)

@@ -54,3 +54,3 @@ Pipe events from one emitter to other

```javascript
var eePipe =require('event-emitter/lib/pipe');
var eePipe = require('event-emitter/lib/pipe');

@@ -77,4 +77,24 @@ var emitter1 = ee(), listener1;

### hasListeners(obj[, type])
Whether given object have registered listeners
```javascript
var emitter = ee();
var hasListeners = require('event-emitter/lib/has-listeners');
var listner = function () {};
hasListeners(emitter); // false
emitter.on('foo', listener);
hasListeners(emitter); // true
hasListeners(emitter, 'foo'); // true
hasListeners(emitter, 'bar'); // false
emitter.off('foo', listener);
hasListeners(emitter, 'foo'); // false
```
## Tests [![Build Status](https://secure.travis-ci.org/medikoo/event-emitter.png?branch=master)](https://secure.travis-ci.org/medikoo/event-emitter)
$ npm test

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