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

eventdispatcher

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eventdispatcher - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

42

dist/eventdispatcher.js

@@ -25,10 +25,7 @@ 'use strict';

this._eventMap = {};
this._destroyed = false;
this._target = null;
this._currentTarget = null;
this.target = target || this;
this.currentTarget = currentTarget || this;
this.eventMap = {};
this.destroyed = false;
this._target = target || this;
this._currentTarget = currentTarget || this;
this.on = this.bind = this.addEventListener = this.addListener;

@@ -43,3 +40,3 @@ this.off = this.unbind = this.removeEventListener = this.removeListener;

if (!listeners) {
this._eventMap[event] = [listener];
this.eventMap[event] = [listener];
} else if (listeners.indexOf(listener) === -1) {

@@ -54,8 +51,7 @@ listeners.push(listener);

var _f = function f2(e) {
var f2 = function f2(e) {
listener(e);
_this.off(event, _f);
_f = null;
_this.off(event, f2);
};
return this.on(event, _f);
return this.on(event, f2);
};

@@ -74,3 +70,3 @@

if (!listeners.length) {
delete this._eventMap[event];
delete this.eventMap[event];
}

@@ -85,4 +81,4 @@ }

if (listeners) {
this._eventMap[event].length = 0;
delete this._eventMap[event];
this.eventMap[event].length = 0;
delete this.eventMap[event];
}

@@ -97,3 +93,3 @@ return this;

EventDispatcher.prototype.hasListeners = function hasListeners() {
return this._eventMap !== null && this._eventMap !== undefined && !isEmpty(this._eventMap);
return this.eventMap !== null && this.eventMap !== undefined && !isEmpty(this.eventMap);
};

@@ -107,4 +103,4 @@

evtObj.type = eventType;
evtObj.target = evtObj.target || this._target;
evtObj.currentTarget = evtObj.currentTarget || this._currentTarget;
evtObj.target = evtObj.target || this.target;
evtObj.currentTarget = evtObj.currentTarget || this.currentTarget;

@@ -120,3 +116,3 @@ var i = -1;

EventDispatcher.prototype.getListener = function getListener(event) {
var result = this._eventMap ? this._eventMap[event] : null;
var result = this.eventMap ? this.eventMap[event] : null;
return result || null;

@@ -126,4 +122,4 @@ };

EventDispatcher.prototype.destroy = function destroy() {
if (this._eventMap) {
var keys = Object.keys(this._eventMap);
if (this.eventMap) {
var keys = Object.keys(this.eventMap);
for (var i = 0; i < keys.length; i++) {

@@ -134,4 +130,4 @@ this.removeAllListener(keys[i]);

this._eventMap = null;
this._destroyed = true;
this.eventMap = null;
this.destroyed = true;
return this;

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

{
"name": "eventdispatcher",
"version": "2.1.0",
"version": "2.1.1",
"description": "EventDispatcher like nodes EventEmitter",

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

@@ -11,11 +11,10 @@ function isEmpty(obj) {

_eventMap = {};
_destroyed = false;
_target = null;
_currentTarget = null;
constructor({ target, currentTarget } = {}) {
this._target = target || this;
this._currentTarget = currentTarget || this;
this.target = target || this;
this.currentTarget = currentTarget || this;
this.eventMap = {};
this.destroyed = false;
this.on = this.bind = this.addEventListener = this.addListener;

@@ -30,3 +29,3 @@ this.off = this.unbind = this.removeEventListener = this.removeListener;

if (!listeners) {
this._eventMap[event] = [listener];
this.eventMap[event] = [listener];
} else if (listeners.indexOf(listener) === -1) {

@@ -39,6 +38,5 @@ listeners.push(listener);

addListenerOnce(event, listener) {
let f2 = (e) => {
const f2 = (e) => {
listener(e);
this.off(event, f2);
f2 = null;
};

@@ -59,3 +57,3 @@ return this.on(event, f2);

if (!listeners.length) {
delete (this._eventMap[event]);
delete (this.eventMap[event]);
}

@@ -70,4 +68,4 @@ }

if (listeners) {
this._eventMap[event].length = 0;
delete (this._eventMap[event]);
this.eventMap[event].length = 0;
delete (this.eventMap[event]);
}

@@ -82,3 +80,3 @@ return this;

hasListeners() {
return (this._eventMap !== null && this._eventMap !== undefined && !isEmpty(this._eventMap));
return (this.eventMap !== null && this.eventMap !== undefined && !isEmpty(this.eventMap));
}

@@ -92,4 +90,4 @@

evtObj.type = eventType;
evtObj.target = evtObj.target || this._target;
evtObj.currentTarget = evtObj.currentTarget || this._currentTarget;
evtObj.target = evtObj.target || this.target;
evtObj.currentTarget = evtObj.currentTarget || this.currentTarget;

@@ -105,3 +103,3 @@ let i = -1;

getListener(event) {
const result = this._eventMap ? this._eventMap[event] : null;
const result = this.eventMap ? this.eventMap[event] : null;
return (result || null);

@@ -111,4 +109,4 @@ }

destroy() {
if (this._eventMap) {
const keys = Object.keys(this._eventMap);
if (this.eventMap) {
const keys = Object.keys(this.eventMap);
for (let i = 0; i < keys.length; i++) {

@@ -119,6 +117,6 @@ this.removeAllListener(keys[i]);

this._eventMap = null;
this._destroyed = true;
this.eventMap = null;
this.destroyed = true;
return this;
}
}
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