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.2024030403 to 2.0.0-dev.2024030501

cjs/index.js

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 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){}}}();
var Emitter=function(e){"use strict";function t(e,t){const a=e.indexOf(t);-1!==a&&e.splice(a,1)}const a={strict:!0,debug:!1,timeout:0,check_passphrase:(e,t)=>e===t};const n={},s={},r={},o={};function l(){}function p(e){var t;return null!==(t=r[e])&&void 0!==t?t:r[e]=[]}function i(e){var t;return null!==(t=n[e])&&void 0!==t?t:n[e]=[]}function c(e){var t;return null!==(t=o[e])&&void 0!==t?t:o[e]=[]}function h(e){var t;return null!==(t=s[e])&&void 0!==t?t:s[e]=[]}function f(e,n,s){let r=[];if("string"==typeof e)r.push(e);else{if(!Array.isArray(e))throw Error("错误的参数:"+e);r=e}if(null==s?void 0:s.passphrase)for(let e=0,o=r.length;e<o;e++){const o=r[e],p=i(o),c=h(o),f=c.filter((e=>a.check_passphrase(e.passphrase,s.passphrase)));if(0===f.length){const e={data_type:"sender",start:(new Date).getTime(),passphrase:s.passphrase,data:n};(null==s?void 0:s.timeout)&&(e.timeout=s.timeout),p.push(e)}else for(let e=0;e<f.length;e++){const a=f[e];"string"===a.event_name_type?a.handle(n,l):a.handle({event_name:o,data:n},l),"once"===a.event_type&&t(c,a)}}else for(let e=0,t=r.length;e<t;e++){const t=r[e],a=p(t),o=c(t);if(0===o.length){const e={data_type:"sender",start:(new Date).getTime(),data:n};(null==s?void 0:s.timeout)&&(e.timeout=s.timeout),a.push(e)}else for(let e=0;e<o.length;e++){const a=o[e];"string"===a.event_name_type?a.handle(n,l):a.handle({event_name:t,data:n},l),"once"===a.event_type&&(o.splice(e,1),e--)}}}function d(e,n=null,s={}){let r,o=[];if("string"==typeof e)r="string",o.push(e);else{if(!Array.isArray(e))throw Error("错误的参数:"+e);r="array",o=e}if(null==s?void 0:s.passphrase){if("function"==typeof n){for(let e=0;e<o.length;e++){const l=o[e],p=i(l),c=p.filter((e=>a.check_passphrase(s.passphrase,e.passphrase))),f=h(l);0!==c.length&&(null==s?void 0:s.once)||f.push({event_type:(null==s?void 0:s.once)?"once":"normal",event_name_type:r,start:(new Date).getTime(),passphrase:s.passphrase,handle:n}),c.forEach((e=>{const a="array"===r?{event_name:l,data:e.data}:e.data;n(a),t(p,e)}))}return()=>u(e,n,s)}for(let e=0,t=o.length;e<t;e++){const t=o[e],n=i(t).filter((e=>a.check_passphrase(s.passphrase,e.passphrase)));if(0!=n.length)return new Promise((e=>{e("array"===r?{event_name:t,data:n.pop().data}:n.pop().data)}))}return new Promise((e=>e(void 0===n?null:n)))}if("function"==typeof n){for(let e=0;e<o.length;e++){const a=o[e],l=p(a),i=c(a);0!==l.length&&(null==s?void 0:s.once)||i.push({event_type:(null==s?void 0:s.once)?"once":"normal",event_name_type:r,start:(new Date).getTime(),handle:n}),l.forEach((e=>{const s="array"===r?{event_name:a,data:e.data}:e.data;"sender"===e.data_type?(n(s),t(l,e)):n(e.data,(()=>t(l,e)))}))}return()=>u(e,n,s)}for(let e=0,a=o.length;e<a;e++){const a=o[e],n=p(a);if(0!=n.length)return new Promise((e=>{const s=n[n.length-1],o="array"===r?{event_name:a,data:s.data}:s.data;"sender"===s.data_type&&t(n,s),e(o)}))}return new Promise((e=>e(void 0===n?null:n)))}function u(e,t=null,n={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(n.passphrase)for(let e=0;e<s.length;e++){const t=s[e];if(n.clear_data){const e=i(t);for(let t=0;t<e.length;t++)a.check_passphrase(n.passphrase,e[t].passphrase)&&(e.splice(t,1),t--)}const r=h(t);for(let e=0;e<r.length;e++)a.check_passphrase(n.passphrase,r[e].passphrase)&&(r.splice(e,1),e--)}else s.forEach((e=>{n.clear_data&&(i(e).length=0),h(e).length=0}));else if(n.passphrase)for(let e=0;e<s.length;e++){const r=s[e];if(n.clear_data){const e=i(r);for(let t=0;t<e.length;t++)a.check_passphrase(n.passphrase,e[t].passphrase)&&(e.splice(t,1),t--)}const o=h(r);for(let e=0;e<o.length;e++)a.check_passphrase(n.passphrase,o[e].passphrase)&&t===o[e].handle&&(o.splice(e,1),e--)}else s.forEach((e=>{const a=c(e);for(let e=0;e<a.length;e++)a[e].handle===t&&(a.splice(e,1),e--)}))}globalThis.__emitter_master={passphrase_data:n,passphrase_handle:s,general_data:r,general_handle:o};const g=d,_=f,m=u;console.log("%cemitter-master:%c 2.0.0-dev.2024030501 %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 v={sender:f,receiver:d,forwarder:function(e,t,a){let n=[];if("string"==typeof e)n.push(e);else{if(!Array.isArray(e))throw Error("错误的参数:"+e);n=e}for(let e=0,s=n.length;e<s;e++){const s=n[e],r=c(s),o={data_type:"forwarder",start:(new Date).getTime(),data:t};(null==a?void 0:a.timeout)&&(o.timeout=a.timeout);const l=p(s);l.push(o);const i=function(){const e=l.indexOf(o);-1!==e&&l.splice(e,1)};if(r.length)for(let e=0;e<r.length;e++){const a=r[e];"string"===a.event_name_type?a.handle(t,i):a.handle({event_name:s,data:t},i),"once"===a.event_type&&(r.splice(e,1),e--)}}},listener:g,trigger:_,clear:u,remove:m,set_config:function(e){}};return e.Emitter=v,e}({});
{
"name": "emitter-master",
"version": "2.0.0-dev.2024030403",
"version": "2.0.0-dev.2024030501",
"description": "Support for offline event emitters, event, listener",
"main": "./cjs/index.cjs",
"main": "./cjs/index.js",
"exports": {
".": {
"import": "./es/index.mjs",
"require": "./cjs/index.cjs",
"import": "./es/index.js",
"require": "./cjs/index.js",
"types": "./emitter.d.ts"
},
"./es": {
"import": "./es/index.mjs",
"default": "./es/index.mjs",
"import": "./es/index.js",
"default": "./es/index.js",
"types": "./emitter.d.ts"
},
"./cjs": {
"require": "./cjs/index.cjs",
"default": "./cjs/index.cjs",
"require": "./cjs/index.js",
"default": "./cjs/index.js",
"types": "./emitter.d.ts"

@@ -24,3 +24,3 @@ }

"browser": "./browser/index.js",
"module": "./es/index.mjs",
"module": "./es/index.js",
"types": "./emitter.d.ts",

@@ -43,3 +43,3 @@ "typing": "./emitter.d.ts",

"type": "git",
"url": "git+https://github.com/Autumn-one/emmit-master.git"
"url": "git+https://github.com/Autumn-one/emitter-master-doc.git"
},

@@ -52,30 +52,22 @@ "keywords": [

"author": "Autumn",
"license": "MPL-2.0",
"license": "None",
"bugs": {
"url": "https://github.com/Autumn-one/emmit-master/issues"
"url": "https://github.com/Autumn-one/emitter-master-doc/issues"
},
"homepage": "https://github.com/Autumn-one/emmit-master#readme",
"homepage": "https://github.com/Autumn-one/emitter-master-doc#readme",
"devDependencies": {
"@babel/core": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"cross-env": "^7.0.3",
"glob": "^8.1.0",
"npm-run-all": "^4.1.5",
"rollup": "^4.12.0",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-livereload": "^2.0.5",
"rollup-plugin-serve": "^1.1.1",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
"vitest": "^1.3.1"
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-terser": "0.4.4",
"glob": "10.3.10",
"rollup": "4.12.0",
"rollup-plugin-dts": "6.1.0",
"rollup-plugin-ts": "3.4.5",
"tslib": "2.6.2",
"typescript": "5.3.3",
"vitest": "1.3.1"
},
"dependencies": {
"@rollup/plugin-typescript": "^11.1.6",
"typescript-treasure": "^0.0.10"
}
}
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