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

@voliware/eventsystem

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@voliware/eventsystem - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

2

dist/eventSystem.min.js

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

class EventSystem{constructor(){this.events={}}generateRandomString(e){let t="",n=()=>{let e=Math.floor(62*Math.random());return e<10?e:e<36?String.fromCharCode(e+55):String.fromCharCode(e+61)};for(;t.length<e;)t+=n();return t}getHandlersCount(e){let t=this.events[e];if(!t)return 0;let n=0,l=[];for(l.push(t);l.length>0;){let e=l.pop();for(let t in e)"handlers"===t?n+=e[t].length:"object"==typeof e[t]&&l.push(e[t])}return n}on(e,t){let n=e.split("."),l=this.events;for(let e=0;e<n.length;e++){let r=n[e];l[r]||(l[r]={}),e===n.length-1?(Array.isArray(l[r].handlers)||(l[r].handlers=[]),l[r].handlers.push(t)):l=l[r]}}one(e,t){let n=this,l=e+"."+this.generateRandomString(16);this.on(l,function(e){t(e),n.off(l)})}off(e,t=!0){let n=e.split("."),l=this.events;for(let e=0;e<n.length;e++){let r=n[e];e===n.length-1?t?delete l[r]:(delete l[r].handlers,0===Object.keys(l[r]).length&&delete l[r]):l=l[r]}}emit(e,t){let n=e.split("."),l=this.events;for(let e=0;e<n.length;e++){if(!(l=l[n[e]]))return this;if(e===n.length-1){let e=[];for(e.push(l);e.length;){let n=e.pop();for(let l in n)if("handlers"===l)for(let e=0;e<n[l].length;e++)n[l][e](t);else e.push(n[l])}}}}}"undefined"!=typeof module&&(module.exports=EventSystem);
class EventSystem{constructor(){this.events={}}generateRandomString(e){let t="",n=()=>{let e=Math.floor(62*Math.random());return e<10?e:e<36?String.fromCharCode(e+55):String.fromCharCode(e+61)};for(;t.length<e;)t+=n();return t}getHandlersCount(e){let t=this.events[e];if(!t)return 0;let n=0,l=[];for(l.push(t);l.length>0;){let e=l.pop();for(let t in e)"handlers"===t?n+=e[t].length:"object"==typeof e[t]&&l.push(e[t])}return n}on(e,t){"string"!=typeof e&&(e+="");let n=e.split("."),l=this.events;for(let e=0;e<n.length;e++){let r=n[e];l[r]||(l[r]={}),e===n.length-1?(Array.isArray(l[r].handlers)||(l[r].handlers=[]),l[r].handlers.push(t)):l=l[r]}}one(e,t){let n=this,l=e+"."+this.generateRandomString(16);this.on(l,function(e){t(e),n.off(l)})}off(e,t=!0){"string"!=typeof e&&(e+="");let n=e.split("."),l=this.events;for(let e=0;e<n.length;e++){let r=n[e];e===n.length-1?t?delete l[r]:(delete l[r].handlers,0===Object.keys(l[r]).length&&delete l[r]):l=l[r]}}emit(e,t){"string"!=typeof e&&(e+="");let n=e.split("."),l=this.events;for(let e=0;e<n.length;e++){if(!(l=l[n[e]]))return this;if(e===n.length-1){let e=[];for(e.push(l);e.length;){let n=e.pop();for(let l in n)if("handlers"===l)for(let e=0;e<n[l].length;e++)n[l][e](t);else e.push(n[l])}}}}}"undefined"!=typeof module&&(module.exports=EventSystem);

@@ -82,2 +82,5 @@ /**

on(event, callback) {
if(typeof event !== "string"){
event = event + '';
}
let event_array = event.split('.');

@@ -127,2 +130,5 @@

off(event, remove_all_child_handlers = true) {
if(typeof event !== "string"){
event = event + '';
}
let event_array = event.split('.');

@@ -155,2 +161,5 @@

emit(event, data) {
if(typeof event !== "string"){
event = event + '';
}
let event_array = event.split('.');

@@ -157,0 +166,0 @@ let last_object = this.events;

{
"name": "@voliware/eventsystem",
"version": "1.0.4",
"version": "1.0.5",
"description": "An event system with on/off/emit functions",

@@ -5,0 +5,0 @@ "main": "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