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

ee-event-emitter

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ee-event-emitter - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

.travis.yml

2

index.js
module.exports = require( "./lib/EventEmitter" );
module.exports = require('./lib/EventEmitter');

@@ -1,36 +0,49 @@

"use strict";
!function(){
'use strict';
var Class = require( "ee-class" )
, log = require( "ee-log" );
var Class = require('ee-class')
, log = require('ee-log');
// cutom events, because they less suck
module.exports = new Class( {
module.exports = new Class({
emit: function( event, err ){
if ( !this.$$$$_events ) Object.defineProperty( this, "$$$$_events", { value: {} } );
___events: {
get: function(){
if (!this.____events) this.____events = {};
return this.____events;
}
}
var args = arguments, i, current;
if ( this.$$$$_events[ event ] ){
i = this.$$$$_events[ event ].length;
while( i-- ){
current = this.$$$$_events[ event ][ i ];
if ( typeof current.listener === "function" ){
current.listener.apply( null, Array.prototype.slice.call( args, 1 ) );
if ( current.once ) this.$$$$_events[ event ].splice( i, 1 );
, emit: function(event, err) {
var args = arguments
, errs
, i
, current;
if (this.___events[event]) {
i = this.___events[event].length;
while(i--) {
current = this.___events[event][i];
if (typeof current.listener === 'function') {
current.listener.apply(null, Array.prototype.slice.call(args, 1));
if (current.once) this.___events[event].splice(i, 1);
}
else {
throw new Error( "cannot emit event [" + event + "], listener is typeof [" + typeof current.listener + "]!" );
this.$$$$_events[ event ].splice( i, 1 );
throw new Error('cannot emit event «'+event+'», listener is typeof «' + typeof current.listener + '»' );
this.___events[ event ].splice( i, 1 );
}
}
}
else if ( event === "error" ){
var errs = Array.prototype.slice.call( args, 1 ).filter( function( a ){ return a instanceof Error; } );
var err = errs.length > 0 ? errs[ 0 ] : new Error( "Emitted an error event without an instance of an error!" );
log.error( "Cannot emit error event without listeners!" );
log.trace( err );
process.exit();
else if (event === 'error') {
errs = Array.prototype.slice.call(args, 1).filter(function(a){
return a instanceof Error;
});
log.error('Cannot emit error event without listeners!');
log.trace(errs[0]);
}

@@ -42,4 +55,4 @@

, listener: function( event ){
return this.$$$$_events && this.$$$$_events[ event ] ? this.$$$$_events[ event ] : [];
, listener: function(event) {
return this.___events && this.___events[event] ? this.___events[event] : [];
}

@@ -49,23 +62,22 @@

// remove all event s( no args ), all listeners of a specific event ( first arg ) or a specific listener ( two args )
, off: function( event, listener ){
, off: function(event, listener) {
var i;
if ( event ){
if ( listener && this.$$$$_events && this.$$$$_events[ event ] ){
i = this.$$$$_events[ event ].length;
while( i-- ){
if ( this.$$$$_events[ event ][ i ].listener === listener ){
this.$$$$_events[ event ].splice( i, 1 );
if (event) {
if (listener && this.___events[event]) {
i = this.___events[event].length;
while(i--) {
if (this.___events[event][i].listener === listener) {
this.___events[event].splice(i, 1);
}
}
}
else {
if ( this.$$$$_events[ event ] ) delete this.$$$$_events[ event ];
}
else if (this.___events[event]) delete this.___events[event];
}
else {
this.$$$$_events = Object.defineProperty( this, "$$$$_events", { value: {} } );;
this.____events = {};
}
this.emit( "removeListener", event, listener );
this.emit('removeListener', event, listener);

@@ -76,22 +88,25 @@ return this;

// add one ( two args ) or multiple events ( one arg -> object ). fired once.
, once: function( event, listener ){
this.on( event, listener, true );
return this;
, once: function(event, listener) {
return this.on(event, listener, true);
}
// add one ( two args ) or multiple events ( one arg -> object ). fired once ( third arg )
, on: function( event, listener, once ){
, on: function(event, listener, once) {
var keys, i;
if ( typeof event === "object" ){
if (typeof event === 'object') {
// multiple events
keys = Object.keys( event );
i = keys.length;
while( i-- ){
this.addListener( keys[ i ], event[ keys[ i ] ], once );
keys = Object.keys(event);
i = keys.length;
while(i--) {
this.addListener(keys[i], event[keys[i]], once);
}
}
else {
this.addListener( event, listener, once );
this.addListener(event, listener, once);
}

@@ -104,13 +119,13 @@

// adds a listenr, somehow private
, addListener: function( event, listener, once ){
if ( !this.$$$$_events ) Object.defineProperty( this, "$$$$_events", { value: {} } );
if ( !this.$$$$_events[ event ] ) this.$$$$_events[ event ] = [];
, addListener: function(event, listener, once) {
if (!this.___events[event]) this.___events[event] = [];
this.emit( "listener", event, listener, once === true );
this.emit('listener', event, listener, once === true);
this.$$$$_events[ event ].push( {
listener: listener
, once: once === true
} );
this.___events[event].push({
listener : listener
, once : !!once
});
}
} );
});
}();
{
"name": "ee-event-emitter"
, "description": "event handler similar to the node.js eventEmitter class"
, "version": "0.1.0"
, "homepage": "https://github.com/eventEmitter/ee-event-emitter"
, "author": "Michael van der Weg <michael@eventemitter.com> (http://eventemitter.com/)"
"name" : "ee-event-emitter"
, "description" : "An EventEmitter implementation"
, "version" : "0.1.1"
, "homepage" : "https://github.com/eventEmitter/ee-event-emitter"
, "author" : "Michael van der Weg <michael@eventemitter.com> (http://eventemitter.com/)"
, "licence" : "mit"
, "repository": {
"url": "https://github.com/eventEmitter/ee-event-emitter"
"url" : "https://github.com/eventEmitter/ee-event-emitter.git"
, "type" : "git"
}
, "engines": {
"node": "*"
"node" : ">=v0.10.0"
}
, "bugs": {
"url": "https://github.com/eventEmitter/ee-event-emitter/issues"
"url" : "https://github.com/eventEmitter/ee-event-emitter/issues"
}
, "dependencies": {
"ee-class": ">=0.1.3"
, "ee-log": "*"
"ee-class" : "1.0.x"
, "ee-log" : "0.2.x"
}
, "devDependencies": {}
, "devDependencies": {
"mocha" : "1.17.x"
}
, "optionalDependencies": {}
, "keywords" : ["event", "eventemitter"]
, "scripts": {
"test" : "node test.js"
}
, "scripts": {
"test" : "./node_modules/mocha/bin/mocha --reporter spec"
}
}
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