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

@evergis/event-emitter

Package Overview
Dependencies
Maintainers
6
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evergis/event-emitter - npm Package Compare versions

Comparing version 1.0.1-alpha.0 to 1.1.0

92

dist/event-emitter.cjs.development.js

@@ -5,4 +5,28 @@ 'use strict';

function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
var EventEmitter = /*#__PURE__*/function () {
function EventEmitter() {
_classCallCheck(this, EventEmitter);
this.handlers = {

@@ -13,40 +37,44 @@ '*': []

var _proto = EventEmitter.prototype;
_createClass(EventEmitter, [{
key: "on",
value: function on(type, handler) {
if (!this.handlers[type]) {
this.handlers[type] = [];
}
_proto.on = function on(type, handler) {
if (!this.handlers[type]) {
this.handlers[type] = [];
this.handlers[type].push(handler);
}
}, {
key: "off",
value: function off(type, handler) {
if (!this.handlers[type]) return;
var index = this.handlers[type].indexOf(handler);
if (index === -1) return;
this.handlers[type].splice(index, 1);
}
}, {
key: "emit",
value: function emit(type, event) {
this.handlers[type] && this.handlers[type].map(function (handler) {
return handler(event);
});
this.handlers['*'].map(function (handler) {
return handler(type, event);
});
}
}, {
key: "once",
value: function once(type, handler) {
var _this = this;
this.handlers[type].push(handler);
};
var onceHandler = function onceHandler(event) {
_this.off(type, onceHandler);
_proto.off = function off(type, handler) {
if (!this.handlers[type]) return;
var index = this.handlers[type].indexOf(handler);
if (index === -1) return;
this.handlers[type].splice(index, 1);
};
handler(event);
};
_proto.emit = function emit(type, event) {
this.handlers[type] && this.handlers[type].map(function (handler) {
return handler(event);
});
this.handlers['*'].map(function (handler) {
return handler(type, event);
});
};
this.on(type, onceHandler);
}
}]);
_proto.once = function once(type, handler) {
var _this = this;
var onceHandler = function onceHandler(event) {
_this.off(type, onceHandler);
handler(event);
};
this.on(type, onceHandler);
};
return EventEmitter;

@@ -53,0 +81,0 @@ }();

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventEmitter=function(){function n(){this.handlers={"*":[]}}var t=n.prototype;return t.on=function(n,t){this.handlers[n]||(this.handlers[n]=[]),this.handlers[n].push(t)},t.off=function(n,t){if(this.handlers[n]){var e=this.handlers[n].indexOf(t);-1!==e&&this.handlers[n].splice(e,1)}},t.emit=function(n,t){this.handlers[n]&&this.handlers[n].map((function(n){return n(t)})),this.handlers["*"].map((function(e){return e(n,t)}))},t.once=function(n,t){var e=this;this.on(n,(function s(i){e.off(n,s),t(i)}))},n}();
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventEmitter=function(){function e(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.handlers={"*":[]}}var n;return(n=[{key:"on",value:function(e,n){this.handlers[e]||(this.handlers[e]=[]),this.handlers[e].push(n)}},{key:"off",value:function(e,n){if(this.handlers[e]){var t=this.handlers[e].indexOf(n);-1!==t&&this.handlers[e].splice(t,1)}}},{key:"emit",value:function(e,n){this.handlers[e]&&this.handlers[e].map((function(e){return e(n)})),this.handlers["*"].map((function(t){return t(e,n)}))}},{key:"once",value:function(e,n){var t=this;this.on(e,(function r(i){t.off(e,r),n(i)}))}}])&&function(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,n),e}();
//# sourceMappingURL=event-emitter.cjs.production.min.js.map

@@ -0,3 +1,27 @@

function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
var EventEmitter = /*#__PURE__*/function () {
function EventEmitter() {
_classCallCheck(this, EventEmitter);
this.handlers = {

@@ -8,40 +32,44 @@ '*': []

var _proto = EventEmitter.prototype;
_createClass(EventEmitter, [{
key: "on",
value: function on(type, handler) {
if (!this.handlers[type]) {
this.handlers[type] = [];
}
_proto.on = function on(type, handler) {
if (!this.handlers[type]) {
this.handlers[type] = [];
this.handlers[type].push(handler);
}
}, {
key: "off",
value: function off(type, handler) {
if (!this.handlers[type]) return;
var index = this.handlers[type].indexOf(handler);
if (index === -1) return;
this.handlers[type].splice(index, 1);
}
}, {
key: "emit",
value: function emit(type, event) {
this.handlers[type] && this.handlers[type].map(function (handler) {
return handler(event);
});
this.handlers['*'].map(function (handler) {
return handler(type, event);
});
}
}, {
key: "once",
value: function once(type, handler) {
var _this = this;
this.handlers[type].push(handler);
};
var onceHandler = function onceHandler(event) {
_this.off(type, onceHandler);
_proto.off = function off(type, handler) {
if (!this.handlers[type]) return;
var index = this.handlers[type].indexOf(handler);
if (index === -1) return;
this.handlers[type].splice(index, 1);
};
handler(event);
};
_proto.emit = function emit(type, event) {
this.handlers[type] && this.handlers[type].map(function (handler) {
return handler(event);
});
this.handlers['*'].map(function (handler) {
return handler(type, event);
});
};
this.on(type, onceHandler);
}
}]);
_proto.once = function once(type, handler) {
var _this = this;
var onceHandler = function onceHandler(event) {
_this.off(type, onceHandler);
handler(event);
};
this.on(type, onceHandler);
};
return EventEmitter;

@@ -48,0 +76,0 @@ }();

{
"version": "1.0.1-alpha.0",
"version": "1.1.0",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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