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

emitter-master

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emitter-master - npm Package Compare versions

Comparing version 2.0.0-dev.2024030402 to 2.0.0-dev.2024030403

2

browser/index.js

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

!function(){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Emitter=void 0;const e=require("../package.json"),t=require("./utils"),r={strict:!0,debug:!1,timeout:0,check_passphrase:(e,t)=>e===t};const a={},s={},n={},o={};function p(){}function l(e){return n[e]??(n[e]=[])}function i(e){return a[e]??(a[e]=[])}function c(e){return o[e]??(o[e]=[])}function h(e){return s[e]??(s[e]=[])}function f(e,a,s){let n=[];if("string"==typeof e)n.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);n=e}if(s?.passphrase)for(let e=0,o=n.length;e<o;e++){const o=n[e],l=i(o),c=h(o),f=c.filter((e=>r.check_passphrase(e.passphrase,s.passphrase)));if(0===f.length){const e={data_type:"sender",start:(new Date).getTime(),passphrase:s.passphrase,data:a};s?.timeout&&(e.timeout=s.timeout),l.push(e)}else for(let e=0;e<f.length;e++){const r=f[e];"string"===r.event_name_type?r.handle(a,p):r.handle({event_name:o,data:a},p),"once"===r.event_type&&(0,t.remove_from_array)(c,r)}}else for(let e=0,t=n.length;e<t;e++){const t=n[e],r=l(t),o=c(t);if(0===o.length){const e={data_type:"sender",start:(new Date).getTime(),data:a};s?.timeout&&(e.timeout=s.timeout),r.push(e)}else for(let e=0;e<o.length;e++){const r=o[e];"string"===r.event_name_type?r.handle(a,p):r.handle({event_name:t,data:a},p),"once"===r.event_type&&(o.splice(e,1),e--)}}}function d(e,a=null,s={}){let n,o=[];if("string"==typeof e)n="string",o.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);n="array",o=e}if(s?.passphrase){if("function"==typeof a){for(let e=0;e<o.length;e++){const p=o[e],l=i(p),c=l.filter((e=>r.check_passphrase(s.passphrase,e.passphrase))),f=h(p);0!==c.length&&s?.once||f.push({event_type:s?.once?"once":"normal",event_name_type:n,start:(new Date).getTime(),passphrase:s.passphrase,handle:a}),c.forEach((e=>{const r="array"===n?{event_name:p,data:e.data}:e.data;a(r),(0,t.remove_from_array)(l,e)}))}return()=>u(e,a,s)}for(let e=0,t=o.length;e<t;e++){const t=o[e],a=i(t).filter((e=>r.check_passphrase(s.passphrase,e.passphrase)));if(0!=a.length)return new Promise((e=>{e("array"===n?{event_name:t,data:a.pop().data}:a.pop().data)}))}return new Promise((e=>e(void 0===a?null:a)))}if("function"==typeof a){for(let e=0;e<o.length;e++){const r=o[e],p=l(r),i=c(r);0!==p.length&&s?.once||i.push({event_type:s?.once?"once":"normal",event_name_type:n,start:(new Date).getTime(),handle:a}),p.forEach((e=>{const s="array"===n?{event_name:r,data:e.data}:e.data;"sender"===e.data_type?(a(s),(0,t.remove_from_array)(p,e)):a(e.data,(()=>(0,t.remove_from_array)(p,e)))}))}return()=>u(e,a,s)}for(let e=0,r=o.length;e<r;e++){const r=o[e],a=l(r);if(0!=a.length)return new Promise((e=>{const s=a[a.length-1],o="array"===n?{event_name:r,data:s.data}:s.data;"sender"===s.data_type&&(0,t.remove_from_array)(a,s),e(o)}))}return new Promise((e=>e(void 0===a?null:a)))}function u(e,t=null,a={clear_data:!1}){let s=[];if("string"==typeof e)s.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);s=e}if(null===t)if(a.passphrase)for(let e=0;e<s.length;e++){const t=s[e];if(a.clear_data){const e=i(t);for(let t=0;t<e.length;t++)r.check_passphrase(a.passphrase,e[t].passphrase)&&(e.splice(t,1),t--)}const n=h(t);for(let e=0;e<n.length;e++)r.check_passphrase(a.passphrase,n[e].passphrase)&&(n.splice(e,1),e--)}else s.forEach((e=>{a.clear_data&&(i(e).length=0),h(e).length=0}));else if(a.passphrase)for(let e=0;e<s.length;e++){const n=s[e];if(a.clear_data){const e=i(n);for(let t=0;t<e.length;t++)r.check_passphrase(a.passphrase,e[t].passphrase)&&(e.splice(t,1),t--)}const o=h(n);for(let e=0;e<o.length;e++)r.check_passphrase(a.passphrase,o[e].passphrase)&&t===o[e].handle&&(o.splice(e,1),e--)}else s.forEach((e=>{const r=c(e);for(let e=0;e<r.length;e++)r[e].handle===t&&(r.splice(e,1),e--)}))}globalThis.__emitter_master={passphrase_data:a,passphrase_handle:s,general_data:n,general_handle:o};const _=d,g=f,m=u;console.log(`%cemitter-master:%c ${e.version} %c=> %curl:%c https://www.npmjs.com/package/emitter-master`,"color: #fff;background: purple;padding: 2px 5px;border-radius:4px;font-size: 14px;","color: purple;font-size:14px;","color: #333;font-size:14px;","background: purple;font-size:14px; padding: 2px 5px; border-radius: 4px; color: #fff;","font-size:14px;");const y={sender:f,receiver:d,forwarder:function(e,t,r){let a=[];if("string"==typeof e)a.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);a=e}for(let s=0,n=a.length;s<n;s++){const o=a[s],p=c(o),i={data_type:"forwarder",start:(new Date).getTime(),data:t};r?.timeout&&(i.timeout=r.timeout);const h=l(o);function f(){const e=h.indexOf(i);-1!==e&&h.splice(e,1)}if(h.push(i),p.length)for(let d=0;d<p.length;d++){const u=p[d];"string"===u.event_name_type?u.handle(t,f):u.handle({event_name:o,data:t},f),"once"===u.event_type&&(p.splice(d,1),d--)}}},listener:_,trigger:g,clear:u,remove:m,set_config:function(e){}};exports.Emitter=y}();
!function(){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Emitter=void 0;const e=require("../package.json"),t=require("./utils"),r={strict:!0,debug:!1,timeout:0,check_passphrase:(e,t)=>e===t};const a={},s={},n={},o={};function p(){}function l(e){return n[e]??(n[e]=[])}function i(e){return a[e]??(a[e]=[])}function c(e){return o[e]??(o[e]=[])}function h(e){return s[e]??(s[e]=[])}function f(e,a,s){let n=[];if("string"==typeof e)n.push(e);else{if(!Array.isArray(e))throw Error("错误的参数:"+e);n=e}if(s?.passphrase)for(let e=0,o=n.length;o>e;e++){const o=n[e],l=i(o),c=h(o),f=c.filter((e=>r.check_passphrase(e.passphrase,s.passphrase)));if(0===f.length){const e={data_type:"sender",start:(new Date).getTime(),passphrase:s.passphrase,data:a};s?.timeout&&(e.timeout=s.timeout),l.push(e)}else for(let e=0;f.length>e;e++){const r=f[e];r.handle("string"===r.event_name_type?a:{event_name:o,data:a},p),"once"===r.event_type&&(0,t.remove_from_array)(c,r)}}else for(let e=0,t=n.length;t>e;e++){const t=n[e],r=l(t),o=c(t);if(0===o.length){const e={data_type:"sender",start:(new Date).getTime(),data:a};s?.timeout&&(e.timeout=s.timeout),r.push(e)}else for(let e=0;o.length>e;e++){const r=o[e];r.handle("string"===r.event_name_type?a:{event_name:t,data:a},p),"once"===r.event_type&&(o.splice(e,1),e--)}}}function d(e,a=null,s={}){let n,o=[];if("string"==typeof e)n="string",o.push(e);else{if(!Array.isArray(e))throw Error("错误的参数:"+e);n="array",o=e}if(s?.passphrase){if("function"==typeof a){for(let e=0;o.length>e;e++){const p=o[e],l=i(p),c=l.filter((e=>r.check_passphrase(s.passphrase,e.passphrase))),f=h(p);0!==c.length&&s?.once||f.push({event_type:s?.once?"once":"normal",event_name_type:n,start:(new Date).getTime(),passphrase:s.passphrase,handle:a}),c.forEach((e=>{a("array"===n?{event_name:p,data:e.data}:e.data),(0,t.remove_from_array)(l,e)}))}return()=>u(e,a,s)}for(let e=0,t=o.length;t>e;e++){const t=o[e],a=i(t).filter((e=>r.check_passphrase(s.passphrase,e.passphrase)));if(0!=a.length)return new Promise((e=>{e("array"===n?{event_name:t,data:a.pop().data}:a.pop().data)}))}return new Promise((e=>e(void 0===a?null:a)))}if("function"==typeof a){for(let e=0;o.length>e;e++){const r=o[e],p=l(r),i=c(r);0!==p.length&&s?.once||i.push({event_type:s?.once?"once":"normal",event_name_type:n,start:(new Date).getTime(),handle:a}),p.forEach((e=>{"sender"===e.data_type?(a("array"===n?{event_name:r,data:e.data}:e.data),(0,t.remove_from_array)(p,e)):a(e.data,(()=>(0,t.remove_from_array)(p,e)))}))}return()=>u(e,a,s)}for(let e=0,r=o.length;r>e;e++){const r=o[e],a=l(r);if(0!=a.length)return new Promise((e=>{const s=a[a.length-1],o="array"===n?{event_name:r,data:s.data}:s.data;"sender"===s.data_type&&(0,t.remove_from_array)(a,s),e(o)}))}return new Promise((e=>e(void 0===a?null:a)))}function u(e,t=null,a={clear_data:!1}){let s=[];if("string"==typeof e)s.push(e);else{if(!Array.isArray(e))throw Error("错误的参数:"+e);s=e}if(null===t)if(a.passphrase)for(let e=0;s.length>e;e++){const t=s[e];if(a.clear_data){const e=i(t);for(let t=0;e.length>t;t++)r.check_passphrase(a.passphrase,e[t].passphrase)&&(e.splice(t,1),t--)}const n=h(t);for(let e=0;n.length>e;e++)r.check_passphrase(a.passphrase,n[e].passphrase)&&(n.splice(e,1),e--)}else s.forEach((e=>{a.clear_data&&(i(e).length=0),h(e).length=0}));else if(a.passphrase)for(let e=0;s.length>e;e++){const n=s[e];if(a.clear_data){const e=i(n);for(let t=0;e.length>t;t++)r.check_passphrase(a.passphrase,e[t].passphrase)&&(e.splice(t,1),t--)}const o=h(n);for(let e=0;o.length>e;e++)r.check_passphrase(a.passphrase,o[e].passphrase)&&t===o[e].handle&&(o.splice(e,1),e--)}else s.forEach((e=>{const r=c(e);for(let e=0;r.length>e;e++)r[e].handle===t&&(r.splice(e,1),e--)}))}globalThis.__emitter_master={passphrase_data:a,passphrase_handle:s,general_data:n,general_handle:o};const _=d,g=f,m=u;console.log(`%cemitter-master:%c ${e.version} %c=> %curl:%c https://www.npmjs.com/package/emitter-master`,"color: #fff;background: purple;padding: 2px 5px;border-radius:4px;font-size: 14px;","color: purple;font-size:14px;","color: #333;font-size:14px;","background: purple;font-size:14px; padding: 2px 5px; border-radius: 4px; color: #fff;","font-size:14px;");exports.Emitter={sender:f,receiver:d,forwarder:function(e,t,r){let a=[];if("string"==typeof e)a.push(e);else{if(!Array.isArray(e))throw Error("错误的参数:"+e);a=e}for(let s=0,n=a.length;n>s;s++){const o=a[s],p=c(o),i={data_type:"forwarder",start:(new Date).getTime(),data:t};r?.timeout&&(i.timeout=r.timeout);const h=l(o);function f(){const e=h.indexOf(i);-1!==e&&h.splice(e,1)}if(h.push(i),p.length)for(let d=0;p.length>d;d++){const u=p[d];u.handle("string"===u.event_name_type?t:{event_name:o,data:t},f),"once"===u.event_type&&(p.splice(d,1),d--)}}},listener:_,trigger:g,clear:u,remove:m,set_config:function(e){}}}();
{
"name": "emitter-master",
"version": "2.0.0-dev.2024030402",
"version": "2.0.0-dev.2024030403",
"description": "Support for offline event emitters, event, listener",

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

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