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

@nodeart/event_emitter

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nodeart/event_emitter - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

20

dist/index.js

@@ -20,3 +20,3 @@ "use strict";

return function (eventName) {
var arrOfSubscribers = this.events[eventName] || [];
var eventsArr = this.events[eventName] || [];

@@ -28,5 +28,5 @@ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

args.forEach(function (fn) {
return arrOfSubscribers.push({ fn: fn, once: once });
return eventsArr.push({ fn: fn, once: once });
});
this.events[eventName] = arrOfSubscribers;
this.events[eventName] = eventsArr;
return this;

@@ -59,4 +59,2 @@ };

EventEmitter.prototype.emit = function (eventName) {
if (!this.events[eventName]) return this;
for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {

@@ -66,9 +64,7 @@ args[_key4 - 1] = arguments[_key4];

for (var i = 0; i < this.events[eventName].length; i++) {
var obj = this.events[eventName][i];
obj.fn.apply(obj, args);
if (obj.once) {
this.events[eventName].splice(i, 1);
}
}
if (!this.events[eventName]) return this;
this.events[eventName] = this.events[eventName].filter(function (elem) {
elem.fn.apply(elem, args);
return !elem.once;
});
return this;

@@ -75,0 +71,0 @@ };

2

dist/index.min.js

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

"use strict";!function t(e,r,n){function o(s,f){if(!r[s]){if(!e[s]){var u="function"==typeof require&&require;if(!f&&u)return u(s,!0);if(i)return i(s,!0);throw new Error("Cannot find module '"+s+"'")}var h=r[s]={exports:{}};e[s][0].call(h.exports,function(t){var r=e[s][1][t];return o(r?r:t)},h,h.exports,t,e,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)o(n[s]);return o}({1:[function(t,e,r){function n(){this.events={}}var o=function(t){return function(e){for(var r=this.events[e]||[],n=arguments.length,o=Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return o.forEach(function(e){return r.push({fn:e,once:t})}),this.events[e]=r,this}},i=o(!1),s=o(!0);n.prototype.on=function(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];return i.apply(this,e)},n.prototype.once=function(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];return s.apply(this,e)},n.prototype.emit=function(t){if(!this.events[t])return this;for(var e=arguments.length,r=Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];for(var o=0;o<this.events[t].length;o++){var i=this.events[t][o];i.fn.apply(i,r),i.once&&this.events[t].splice(o,1)}return this},n.prototype.off=function(t){for(var e=arguments.length,r=Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return this.events[t]?(r.length>0?this.events[t]=this.events[t].filter(function(t){return!r.includes(t.fn)}):delete this.events[t],this):this},n.prototype.offAll=function(){return this.events={},this},void 0!==e&&e.exports&&(e.exports=n),"undefined"!=typeof window&&document&&(window.EventEmitter=n)},{}]},{},[1]);
"use strict";!function t(n,e,r){function o(f,u){if(!e[f]){if(!n[f]){var s="function"==typeof require&&require;if(!u&&s)return s(f,!0);if(i)return i(f,!0);throw new Error("Cannot find module '"+f+"'")}var h=e[f]={exports:{}};n[f][0].call(h.exports,function(t){var e=n[f][1][t];return o(e?e:t)},h,h.exports,t,n,e,r)}return e[f].exports}for(var i="function"==typeof require&&require,f=0;f<r.length;f++)o(r[f]);return o}({1:[function(t,n,e){function r(){this.events={}}var o=function(t){return function(n){for(var e=this.events[n]||[],r=arguments.length,o=Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.forEach(function(n){return e.push({fn:n,once:t})}),this.events[n]=e,this}},i=o(!1),f=o(!0);r.prototype.on=function(){for(var t=arguments.length,n=Array(t),e=0;e<t;e++)n[e]=arguments[e];return i.apply(this,n)},r.prototype.once=function(){for(var t=arguments.length,n=Array(t),e=0;e<t;e++)n[e]=arguments[e];return f.apply(this,n)},r.prototype.emit=function(t){for(var n=arguments.length,e=Array(n>1?n-1:0),r=1;r<n;r++)e[r-1]=arguments[r];return this.events[t]?(this.events[t]=this.events[t].filter(function(t){return t.fn.apply(t,e),!t.once}),this):this},r.prototype.off=function(t){for(var n=arguments.length,e=Array(n>1?n-1:0),r=1;r<n;r++)e[r-1]=arguments[r];return this.events[t]?(e.length>0?this.events[t]=this.events[t].filter(function(t){return!e.includes(t.fn)}):delete this.events[t],this):this},r.prototype.offAll=function(){return this.events={},this},void 0!==n&&n.exports&&(n.exports=r),"undefined"!=typeof window&&document&&(window.EventEmitter=r)},{}]},{},[1]);
{
"name": "@nodeart/event_emitter",
"version": "1.0.2",
"version": "1.0.3",
"description": "Simple EventEmitter pattern",

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

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