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 1.0.17 to 1.0.19-beta.20230724

2

browser/index.js

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

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

@@ -1,19 +0,27 @@

type EventData = any;
type EventArg<T extends string | readonly string[] = string> = {
event_name: T extends string ? T : T[number];
data: any;
};
declare function receiver(event_name: string): Promise<null | any>;
declare function receiver(event_name: string, handle: (arg: EventData) => any): () => any;
declare function receiver<const DefaultType>(event_name: string, default_value: DefaultType): Promise<any | DefaultType>;
declare function receiver<const T extends readonly string[]>(event_names: T): Promise<null | EventArg<T>>;
declare function receiver<const T extends readonly string[]>(event_names: T, handle: (arg: EventArg<T>) => any): () => any;
declare function receiver<const T extends readonly string[], const DefaultType>(event_names: T, default_value: DefaultType): Promise<DefaultType | EventArg<T>>;
declare function once(event_name: string): Promise<null | any>;
declare function once(event_name: string, handle: (data: EventData) => any): () => any;
declare function once<const DefaultType>(event_name: string, default_value: DefaultType): Promise<DefaultType | any>;
declare function once<const T extends readonly string[]>(event_names: T): Promise<EventArg<T> | null>;
declare function once<const T extends readonly string[]>(event_names: T, handle: (arg: EventArg<T>) => any): () => any;
declare function once<const T extends readonly string[], const DefaultType>(event_name: T, default_value: DefaultType): Promise<DefaultType | EventArg<T>>;
declare function sender(event_names: string | string[], data: any): void;
interface EmitterMasterEventMap {
}
/**
* 接收者会接收到的数据
* @param K 一个事件名称
* @returns 事件的对应接收数据的类型
*/
type ReceiverData<K extends string | symbol> = K extends keyof EmitterMasterEventMap ? (EmitterMasterEventMap[K] extends never ? (never) : (EmitterMasterEventMap[K])) : (never);
type ReceiverArrData<T extends readonly any[]> = T[number] extends infer K ? (K extends keyof EmitterMasterEventMap ? ({
event_name: K;
data: EmitterMasterEventMap[K];
}) : (never)) : never;
type ClearFn = () => any;
declare function receiver<const E extends string>(event_name: E): Promise<null | ReceiverData<E>>;
declare function receiver<const E extends string>(event_name: E, handle: (arg: ReceiverData<E>) => any): ClearFn;
declare function receiver<const DefaultType, const E extends string>(event_name: E, default_value: DefaultType): Promise<ReceiverData<E> | DefaultType>;
declare function receiver<const T extends readonly string[]>(event_names: T): Promise<null | ReceiverArrData<T>>;
declare function receiver<const T extends readonly string[]>(event_names: T, handle: (arg: ReceiverArrData<T>) => any): ClearFn;
declare function receiver<const T extends readonly string[], const DefaultType>(event_names: T, default_value: DefaultType): Promise<DefaultType | ReceiverArrData<T>>;
declare function once<const E extends string>(event_name: E): Promise<null | ReceiverData<E>>;
declare function once<const E extends string>(event_name: E, handle: (arg: ReceiverData<E>) => any): ClearFn;
declare function once<const DefaultType, const E extends string>(event_name: E, default_value: DefaultType): Promise<ReceiverData<E> | DefaultType>;
declare function once<const T extends readonly string[]>(event_names: T): Promise<null | ReceiverArrData<T>>;
declare function once<const T extends readonly string[]>(event_names: T, handle: (arg: ReceiverArrData<T>) => any): ClearFn;
declare function once<const T extends readonly string[], const DefaultType>(event_names: T, default_value: DefaultType): Promise<DefaultType | ReceiverArrData<T>>;
declare function sender<T extends keyof EmitterMasterEventMap | (keyof EmitterMasterEventMap)[]>(event_names: T, data: T extends keyof EmitterMasterEventMap ? EmitterMasterEventMap[T] : EmitterMasterEventMap[T[number]]): void;
interface EventConfig {

@@ -26,2 +34,4 @@ offline: boolean;

declare const Emitter: {
timeout: number;
debug: boolean;
sender: typeof sender;

@@ -28,0 +38,0 @@ receiver: typeof receiver;

{
"name": "emitter-master",
"version": "1.0.17",
"version": "1.0.19-beta.20230724",
"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