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 1.3.1 to 1.4.0

21

dist/eventdispatcher.js

@@ -38,10 +38,6 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.EventDispatcher = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

this._eventMap[event] = [listener];
return true;
}
if (listeners.indexOf(listener) === -1) {
}else if (listeners.indexOf(listener) === -1) {
listeners.push(listener);
return true;
}
return false;
return this;
};

@@ -72,6 +68,5 @@

}
return true;
}
}
return false;
return this;
};

@@ -84,5 +79,4 @@

delete(this._eventMap[event]);
return true;
}
return false;
return this;
};

@@ -110,5 +104,5 @@

}
return true;
// return true;
}
return false;
return this;
};

@@ -129,2 +123,3 @@

this._destroyed = true;
return this;
};

@@ -136,2 +131,2 @@

});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJzcmMvaW5kZXguanMiXSwibmFtZXMiOltdLCJtYXBwaW5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module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g.EventDispatcher=f()}}(function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";function isEmpty(obj){for(var prop in obj)if(obj.hasOwnProperty(prop))return!1;return!0}var _instanceMap={},EventDispatcher=function(){this._eventMap={},this._destroyed=!1,this.on=this.bind=this.addEventListener=this.addListener,this.off=this.unbind=this.removeEventListener=this.removeListener,this.once=this.one=this.addListenerOnce,this.emmit=this.trigger=this.dispatchEvent=this.dispatch};EventDispatcher.getInstance=function(key){if(!key)throw new Error("key must be");return _instanceMap[key]||(_instanceMap[key]=new EventDispatcher)},EventDispatcher.prototype.addListener=function(event,listener){var listeners=this.getListener(event);return listeners?-1===listeners.indexOf(listener)?(listeners.push(listener),!0):!1:(this._eventMap[event]=[listener],!0)},EventDispatcher.prototype.addListenerOnce=function(event,listener){var s=this,f2=function(){return s.removeListener(event,f2),listener.apply(this,arguments)};return this.addListener(event,f2)},EventDispatcher.prototype.removeListener=function(event,listener){if("undefined"==typeof listener)return this.removeAllListener(event);var listeners=this.getListener(event);if(listeners){var i=listeners.indexOf(listener);if(i>-1)return listeners=listeners.splice(i,1),listeners.length||delete this._eventMap[event],!0}return!1},EventDispatcher.prototype.removeAllListener=function(event){var listeners=this.getListener(event);return listeners?(this._eventMap[event].length=0,delete this._eventMap[event],!0):!1},EventDispatcher.prototype.hasListener=function(event){return null!==this.getListener(event)},EventDispatcher.prototype.hasListeners=function(){return null!==this._eventMap&&void 0!==this._eventMap&&!isEmpty(this._eventMap)},EventDispatcher.prototype.dispatch=function(eventType,eventObject){var listeners=this.getListener(eventType);if(listeners){eventObject=eventObject||{},eventObject.type=eventType,eventObject.target=eventObject.target||this;for(var i=-1;++i<listeners.length;)listeners[i](eventObject);return!0}return!1},EventDispatcher.prototype.getListener=function(event){var result=this._eventMap?this._eventMap[event]:null;return result||null},EventDispatcher.prototype.destroy=function(){if(this._eventMap){for(var i in this._eventMap)this.removeAllListener(i);this._eventMap=null}this._destroyed=!0},module.exports=EventDispatcher},{}]},{},[1])(1)});
!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g.EventDispatcher=f()}}(function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";function isEmpty(obj){for(var prop in obj)if(obj.hasOwnProperty(prop))return!1;return!0}var _instanceMap={},EventDispatcher=function(){this._eventMap={},this._destroyed=!1,this.on=this.bind=this.addEventListener=this.addListener,this.off=this.unbind=this.removeEventListener=this.removeListener,this.once=this.one=this.addListenerOnce,this.emmit=this.trigger=this.dispatchEvent=this.dispatch};EventDispatcher.getInstance=function(key){if(!key)throw new Error("key must be");return _instanceMap[key]||(_instanceMap[key]=new EventDispatcher)},EventDispatcher.prototype.addListener=function(event,listener){var listeners=this.getListener(event);return listeners?-1===listeners.indexOf(listener)&&listeners.push(listener):this._eventMap[event]=[listener],this},EventDispatcher.prototype.addListenerOnce=function(event,listener){var s=this,f2=function(){return s.removeListener(event,f2),listener.apply(this,arguments)};return this.addListener(event,f2)},EventDispatcher.prototype.removeListener=function(event,listener){if("undefined"==typeof listener)return this.removeAllListener(event);var listeners=this.getListener(event);if(listeners){var i=listeners.indexOf(listener);i>-1&&(listeners=listeners.splice(i,1),listeners.length||delete this._eventMap[event])}return this},EventDispatcher.prototype.removeAllListener=function(event){var listeners=this.getListener(event);return listeners&&(this._eventMap[event].length=0,delete this._eventMap[event]),this},EventDispatcher.prototype.hasListener=function(event){return null!==this.getListener(event)},EventDispatcher.prototype.hasListeners=function(){return null!==this._eventMap&&void 0!==this._eventMap&&!isEmpty(this._eventMap)},EventDispatcher.prototype.dispatch=function(eventType,eventObject){var listeners=this.getListener(eventType);if(listeners){eventObject=eventObject||{},eventObject.type=eventType,eventObject.target=eventObject.target||this;for(var i=-1;++i<listeners.length;)listeners[i](eventObject)}return this},EventDispatcher.prototype.getListener=function(event){var result=this._eventMap?this._eventMap[event]:null;return result||null},EventDispatcher.prototype.destroy=function(){if(this._eventMap){for(var i in this._eventMap)this.removeAllListener(i);this._eventMap=null}return this._destroyed=!0,this},module.exports=EventDispatcher},{}]},{},[1])(1)});
{
"name": "eventdispatcher",
"version": "1.3.1",
"version": "1.4.0",
"description": "EventDispatcher like nodes EventEmitter",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -37,10 +37,6 @@ 'use strict';

this._eventMap[event] = [listener];
return true;
}
if (listeners.indexOf(listener) === -1) {
}else if (listeners.indexOf(listener) === -1) {
listeners.push(listener);
return true;
}
return false;
return this;
};

@@ -71,6 +67,5 @@

}
return true;
}
}
return false;
return this;
};

@@ -83,5 +78,4 @@

delete(this._eventMap[event]);
return true;
}
return false;
return this;
};

@@ -109,5 +103,5 @@

}
return true;
// return true;
}
return false;
return this;
};

@@ -128,4 +122,5 @@

this._destroyed = true;
return this;
};
module.exports = EventDispatcher;

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