New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

emitter-master

Package Overview
Dependencies
Maintainers
1
Versions
24
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 1.0.8 to 1.0.9

2

browser/index.js

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

var Emitter=function(e){"use strict";const a={},p={};function f(e){return p[e]??(p[e]=[])}function c(e){return a[e]??(a[e]=[])}function r(e,n){let t=[],o;if("string"==typeof e)o="string",t.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);o="array",t=e}if(n instanceof Function){for(let e=0,r=t.length;e<r;e++){var l=t[e],a=c(l);for(let e=0,r=a.length;e<r;e++)"array"===o?n({event_name:l,data:a[e]}):n(a[e]);a.length=0,p[l].push({type:"normal",event_name_type:o,handle:n})}return n}for(let e=0,r=t.length;e<r;e++){const i=t[e],f=c(i);if(0!=f.length)return new Promise(e=>{"array"===o?e({event_name:i,data:f.pop()}):e(f.pop())})}return new Promise(e=>e(void 0===n?null:n))}function n(e,n){let t=[];if("string"==typeof e)t.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);t=e}for(let r=0,e=t.length;r<e;r++){var o=t[r],l=f(o);if(0===l.length)c(o).push(n);else for(let e=0;e<l.length;e++){var a=l[r];"string"===a.event_name_type?a.handle(n):a.handle({event_name:o,data:n}),"once"===a.type&&(l.splice(e,1),e--)}}}function t(e,r){let n=[];if("string"==typeof e)n.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);n=e}var t={offline:!1};if(void 0!==r&&("function"==typeof r?t.callback=r:(void 0!==r.offline&&(t.offline=r.offline),void 0!==r.callback&&(t.callback=r.callback))),void 0===t.callback)for(let e=0,r=n.length;e<r;e++){var o=n[e];t.offline&&(a[o].length=0),p[o].length=0}else for(let e=0,r=n.length;e<r;e++){var l=f(n[e]);for(let e=0;e<l.length;e++)l[e].handle===t.callback&&(l.splice(e,1),e--)}}r("abc",888);var o=r,l=n,i=t,l=(console.log("%cemitter-master:%c 1.0.8 %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;"),{sender:l,receiver:o,listener:r,once:function(e,n){let t=[],o;if("string"==typeof e)o="string",t.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);o="array",t=e}if(n instanceof Function){for(let e=0,r=t.length;e<r;e++){var l=t[e],a=c(l);0===a.length?f(l).push({type:"once",event_name_type:o,handle:n}):"array"===o?n({event_name:l,data:a.pop()}):n(a.pop())}return n}for(let e=0;e<t.length;e++){const r=t[e],i=c(r);if(0!==i.length)return new Promise(e=>"array"===o?e({event_name:r,data:i.pop()}):e(i.pop()))}return new Promise(e=>e(void 0===n?null:n))},trigger:n,clear:t,debug_print:function(){console.log("事件缓存--\x3e",p),console.log("离线缓存--\x3e",a)},remove:i});return e.Emitter=l,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
var Emitter=function(e){"use strict";const a={},p={};function f(e){return p[e]??(p[e]=[])}function s(e){return a[e]??(a[e]=[])}function r(e,n){let t=[],o;if("string"==typeof e)o="string",t.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);o="array",t=e}if("function"==typeof n){for(let e=0,r=t.length;e<r;e++){var l=t[e],a=s(l);for(let e=0,r=a.length;e<r;e++)"array"===o?n({event_name:l,data:a[e]}):n(a[e]);a.length=0,p[l].push({type:"normal",event_name_type:o,handle:n})}return()=>c(e,n)}for(let e=0,r=t.length;e<r;e++){const i=t[e],f=s(i);if(0!=f.length)return new Promise(e=>{"array"===o?e({event_name:i,data:f.pop()}):e(f.pop())})}return new Promise(e=>e(void 0===n?null:n))}function n(e,n){let t=[];if("string"==typeof e)t.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);t=e}for(let r=0,e=t.length;r<e;r++){var o=t[r],l=f(o);if(0===l.length)s(o).push(n);else for(let e=0;e<l.length;e++){var a=l[r];"string"===a.event_name_type?a.handle(n):a.handle({event_name:o,data:n}),"once"===a.type&&(l.splice(e,1),e--)}}}function c(e,r){let n=[];if("string"==typeof e)n.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);n=e}var t={offline:!1};if(void 0!==r&&("function"==typeof r?t.callback=r:(void 0!==r.offline&&(t.offline=r.offline),void 0!==r.callback&&(t.callback=r.callback))),void 0===t.callback)for(let e=0,r=n.length;e<r;e++){var o=n[e];t.offline&&(a[o].length=0),p[o].length=0}else for(let e=0,r=n.length;e<r;e++){var l=f(n[e]);for(let e=0;e<l.length;e++)l[e].handle===t.callback&&(l.splice(e,1),e--)}}var t=r,o=n,l=c,o=(console.log("%cemitter-master:%c 1.0.9 %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;"),{sender:o,receiver:t,listener:r,once:function(e,n){let t=[],o;if("string"==typeof e)o="string",t.push(e);else{if(!Array.isArray(e))throw new Error("错误的参数:"+e);o="array",t=e}if("function"==typeof n){for(let e=0,r=t.length;e<r;e++){var l=t[e],a=s(l);0===a.length?f(l).push({type:"once",event_name_type:o,handle:n}):"array"===o?n({event_name:l,data:a.pop()}):n(a.pop())}return()=>c(e,n)}for(let e=0;e<t.length;e++){const r=t[e],i=s(r);if(0!==i.length)return new Promise(e=>"array"===o?e({event_name:r,data:i.pop()}):e(i.pop()))}return new Promise(e=>e(void 0===n?null:n))},trigger:n,clear:c,debug_print:function(){console.log("事件缓存--\x3e",p),console.log("离线缓存--\x3e",a)},remove:l});return e.Emitter=o,Object.defineProperty(e,"__esModule",{value:!0}),e}({});

@@ -7,12 +7,12 @@ type EventData = any;

declare function listener(event_name: string): Promise<null | any>;
declare function listener(event_name: string, handle: (arg: EventData) => any): (arg: EventData) => any;
declare function listener(event_name: string, handle: (arg: EventData) => any): Function;
declare function listener(event_name: string, default_value: any): Promise<any>;
declare function listener(event_names: string[]): Promise<null | any>;
declare function listener(event_names: string[], handle: (arg: EventArg) => any): (arg: EventArg) => any;
declare function listener(event_names: string[], handle: (arg: EventArg) => any): Function;
declare function listener(event_names: string[], default_value: any): Promise<any>;
declare function once(event_name: string): Promise<null | any>;
declare function once(event_name: string, handle: (data: EventData) => any): (data: EventData) => any;
declare function once(event_name: string, handle: (data: EventData) => any): Function;
declare function once(event_name: string, default_value: any): Promise<any>;
declare function once(event_names: string[]): Promise<EventArg | null>;
declare function once(event_names: string[], handle: (arg: EventArg) => any): (arg: EventArg) => any;
declare function once(event_names: string[], handle: (arg: EventArg) => any): Function;
declare function once(event_name: string[], default_value: any): Promise<any | EventArg>;

@@ -19,0 +19,0 @@ declare function trigger(event_names: string | string[], data: any): void;

{
"name": "emitter-master",
"version": "1.0.8",
"version": "1.0.9",
"description": "Support for offline event emitters, event, listener",

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

@@ -13,3 +13,3 @@ # emitter-master

// or
Emitter.receiver("A<->B",function(val){
const clear_emitter = Emitter.receiver("A<->B",function(val){
console.log(val)

@@ -19,3 +19,3 @@ })

// clear
Emitter.clear("A<->B")
clear_emitter()
```

@@ -34,5 +34,8 @@

Emitter.receiver(["A->B", "B->C"], handle)
const clear = Emitter.receiver(["A->B", "B->C"], handle)
// There are two ways to clear a listener
Emitter.clear(["A->B", "B->C"], handle)
// or
clear()
```

@@ -48,3 +51,3 @@

Depending on your scenario, the name you use will provide better semantics.
You can choose a more appropriate name based on your scene

@@ -51,0 +54,0 @@ ## Recommendation specifications in vue and react

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