Comparing version 1.5.0 to 1.5.1
@@ -1,2 +0,2 @@ | ||
"use strict";(()=>{var L=Object.defineProperty;var c=(i,e,t)=>e in i?L(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e,t)=>c(i,typeof e!="symbol"?e+"":e,t);var l=class{constructor(){o(this,"_eventListeners");o(this,"_maxListeners");this._eventListeners=new Map,this._maxListeners=100}once(e,t){let s=(...n)=>{this.off(e,s),t(...n)};return this.on(e,s),this}listenerCount(e){if(!e)return this.getAllListeners().length;let t=this._eventListeners.get(e);return t?t.length:0}eventNames(){return Array.from(this._eventListeners.keys())}rawListeners(e){return e?this._eventListeners.get(e)??[]:this.getAllListeners()}prependListener(e,t){let s=this._eventListeners.get(e)??[];return s.unshift(t),this._eventListeners.set(e,s),this}prependOnceListener(e,t){let s=(...n)=>{this.off(e,s),t(...n)};return this.prependListener(e,s),this}maxListeners(){return this._maxListeners}addListener(e,t){return this.on(e,t),this}on(e,t){this._eventListeners.has(e)||this._eventListeners.set(e,[]);let s=this._eventListeners.get(e);return s&&(s.length>=this._maxListeners&&console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length+1} ${e} listeners added. Use setMaxListeners() to increase limit.`),s.push(t)),this}removeListener(e,t){return this.off(e,t),this}off(e,t){let s=this._eventListeners.get(e)??[],n=s.indexOf(t);return n>-1&&s.splice(n,1),s.length===0&&this._eventListeners.delete(e),this}emit(e,...t){let s=!1,n=this._eventListeners.get(e);if(n&&n.length>0)for(let r of n)r(...t),s=!0;return s}listeners(e){return this._eventListeners.get(e)??[]}removeAllListeners(e){return e?this._eventListeners.delete(e):this._eventListeners.clear(),this}setMaxListeners(e){this._maxListeners=e;for(let t of this._eventListeners.values())t.length>e&&t.splice(e)}getAllListeners(){let e=new Array;for(let t of this._eventListeners.values())e=e.concat(t);return e}};var h=class extends l{constructor(){super();o(this,"_hooks");this._hooks=new Map}onHook(t,s){let n=this._hooks.get(t);n?n.push(s):this._hooks.set(t,[s])}onceHook(t,s){let n=async(...r)=>(this.removeHook(t,n),s(...r));this.onHook(t,n)}removeHook(t,s){let n=this._hooks.get(t);if(n){let r=n.indexOf(s);r!==-1&&n.splice(r,1)}}async hook(t,...s){let n=this._hooks.get(t);if(n)for(let r of n)try{await r(...s)}catch(a){this.emit("error",new Error(`Error in hook handler for event "${t}": ${a.message}`))}}get hooks(){return this._hooks}getHooks(t){return this._hooks.get(t)}clearHooks(){this._hooks.clear()}};})(); | ||
"use strict";(()=>{var v=Object.defineProperty;var g=(i,e,t)=>e in i?v(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e,t)=>g(i,typeof e!="symbol"?e+"":e,t);var l=class{constructor(){o(this,"_eventListeners");o(this,"_maxListeners");this._eventListeners=new Map,this._maxListeners=100}once(e,t){let s=(...n)=>{this.off(e,s),t(...n)};return this.on(e,s),this}listenerCount(e){if(!e)return this.getAllListeners().length;let t=this._eventListeners.get(e);return t?t.length:0}eventNames(){return Array.from(this._eventListeners.keys())}rawListeners(e){return e?this._eventListeners.get(e)??[]:this.getAllListeners()}prependListener(e,t){let s=this._eventListeners.get(e)??[];return s.unshift(t),this._eventListeners.set(e,s),this}prependOnceListener(e,t){let s=(...n)=>{this.off(e,s),t(...n)};return this.prependListener(e,s),this}maxListeners(){return this._maxListeners}addListener(e,t){return this.on(e,t),this}on(e,t){this._eventListeners.has(e)||this._eventListeners.set(e,[]);let s=this._eventListeners.get(e);return s&&(s.length>=this._maxListeners&&console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length+1} ${e} listeners added. Use setMaxListeners() to increase limit.`),s.push(t)),this}removeListener(e,t){return this.off(e,t),this}off(e,t){let s=this._eventListeners.get(e)??[],n=s.indexOf(t);return n>-1&&s.splice(n,1),s.length===0&&this._eventListeners.delete(e),this}emit(e,...t){let s=!1,n=this._eventListeners.get(e);if(n&&n.length>0)for(let r of n)r(...t),s=!0;return s}listeners(e){return this._eventListeners.get(e)??[]}removeAllListeners(e){return e?this._eventListeners.delete(e):this._eventListeners.clear(),this}setMaxListeners(e){this._maxListeners=e;for(let t of this._eventListeners.values())t.length>e&&t.splice(e)}getAllListeners(){let e=new Array;for(let t of this._eventListeners.values())e=e.concat(t);return e}};var m=class extends l{constructor(){super();o(this,"_hooks");this._hooks=new Map}onHook(t,s){let n=this._hooks.get(t);n?n.push(s):this._hooks.set(t,[s])}onceHook(t,s){let n=async(...r)=>(this.removeHook(t,n),s(...r));this.onHook(t,n)}removeHook(t,s){let n=this._hooks.get(t);if(n){let r=n.indexOf(s);r!==-1&&n.splice(r,1)}}async hook(t,...s){let n=this._hooks.get(t);if(n)for(let r of n)try{await r(...s)}catch(a){this.emit("error",new Error(`Error in hook handler for event "${t}": ${a.message}`))}}get hooks(){return this._hooks}getHooks(t){return this._hooks.get(t)}clearHooks(){this._hooks.clear()}};})(); | ||
//# sourceMappingURL=index.global.js.map |
@@ -1,2 +0,2 @@ | ||
var L=Object.defineProperty;var c=(i,e,t)=>e in i?L(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e,t)=>c(i,typeof e!="symbol"?e+"":e,t);var l=class{constructor(){o(this,"_eventListeners");o(this,"_maxListeners");this._eventListeners=new Map,this._maxListeners=100}once(e,t){let s=(...n)=>{this.off(e,s),t(...n)};return this.on(e,s),this}listenerCount(e){if(!e)return this.getAllListeners().length;let t=this._eventListeners.get(e);return t?t.length:0}eventNames(){return Array.from(this._eventListeners.keys())}rawListeners(e){return e?this._eventListeners.get(e)??[]:this.getAllListeners()}prependListener(e,t){let s=this._eventListeners.get(e)??[];return s.unshift(t),this._eventListeners.set(e,s),this}prependOnceListener(e,t){let s=(...n)=>{this.off(e,s),t(...n)};return this.prependListener(e,s),this}maxListeners(){return this._maxListeners}addListener(e,t){return this.on(e,t),this}on(e,t){this._eventListeners.has(e)||this._eventListeners.set(e,[]);let s=this._eventListeners.get(e);return s&&(s.length>=this._maxListeners&&console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length+1} ${e} listeners added. Use setMaxListeners() to increase limit.`),s.push(t)),this}removeListener(e,t){return this.off(e,t),this}off(e,t){let s=this._eventListeners.get(e)??[],n=s.indexOf(t);return n>-1&&s.splice(n,1),s.length===0&&this._eventListeners.delete(e),this}emit(e,...t){let s=!1,n=this._eventListeners.get(e);if(n&&n.length>0)for(let r of n)r(...t),s=!0;return s}listeners(e){return this._eventListeners.get(e)??[]}removeAllListeners(e){return e?this._eventListeners.delete(e):this._eventListeners.clear(),this}setMaxListeners(e){this._maxListeners=e;for(let t of this._eventListeners.values())t.length>e&&t.splice(e)}getAllListeners(){let e=new Array;for(let t of this._eventListeners.values())e=e.concat(t);return e}};var h=class extends l{constructor(){super();o(this,"_hooks");this._hooks=new Map}onHook(t,s){let n=this._hooks.get(t);n?n.push(s):this._hooks.set(t,[s])}onceHook(t,s){let n=async(...r)=>(this.removeHook(t,n),s(...r));this.onHook(t,n)}removeHook(t,s){let n=this._hooks.get(t);if(n){let r=n.indexOf(s);r!==-1&&n.splice(r,1)}}async hook(t,...s){let n=this._hooks.get(t);if(n)for(let r of n)try{await r(...s)}catch(a){this.emit("error",new Error(`Error in hook handler for event "${t}": ${a.message}`))}}get hooks(){return this._hooks}getHooks(t){return this._hooks.get(t)}clearHooks(){this._hooks.clear()}};export{l as Eventified,h as Hookified}; | ||
var v=Object.defineProperty;var g=(i,e,t)=>e in i?v(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e,t)=>g(i,typeof e!="symbol"?e+"":e,t);var l=class{constructor(){o(this,"_eventListeners");o(this,"_maxListeners");this._eventListeners=new Map,this._maxListeners=100}once(e,t){let s=(...n)=>{this.off(e,s),t(...n)};return this.on(e,s),this}listenerCount(e){if(!e)return this.getAllListeners().length;let t=this._eventListeners.get(e);return t?t.length:0}eventNames(){return Array.from(this._eventListeners.keys())}rawListeners(e){return e?this._eventListeners.get(e)??[]:this.getAllListeners()}prependListener(e,t){let s=this._eventListeners.get(e)??[];return s.unshift(t),this._eventListeners.set(e,s),this}prependOnceListener(e,t){let s=(...n)=>{this.off(e,s),t(...n)};return this.prependListener(e,s),this}maxListeners(){return this._maxListeners}addListener(e,t){return this.on(e,t),this}on(e,t){this._eventListeners.has(e)||this._eventListeners.set(e,[]);let s=this._eventListeners.get(e);return s&&(s.length>=this._maxListeners&&console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length+1} ${e} listeners added. Use setMaxListeners() to increase limit.`),s.push(t)),this}removeListener(e,t){return this.off(e,t),this}off(e,t){let s=this._eventListeners.get(e)??[],n=s.indexOf(t);return n>-1&&s.splice(n,1),s.length===0&&this._eventListeners.delete(e),this}emit(e,...t){let s=!1,n=this._eventListeners.get(e);if(n&&n.length>0)for(let r of n)r(...t),s=!0;return s}listeners(e){return this._eventListeners.get(e)??[]}removeAllListeners(e){return e?this._eventListeners.delete(e):this._eventListeners.clear(),this}setMaxListeners(e){this._maxListeners=e;for(let t of this._eventListeners.values())t.length>e&&t.splice(e)}getAllListeners(){let e=new Array;for(let t of this._eventListeners.values())e=e.concat(t);return e}};var m=class extends l{constructor(){super();o(this,"_hooks");this._hooks=new Map}onHook(t,s){let n=this._hooks.get(t);n?n.push(s):this._hooks.set(t,[s])}onceHook(t,s){let n=async(...r)=>(this.removeHook(t,n),s(...r));this.onHook(t,n)}removeHook(t,s){let n=this._hooks.get(t);if(n){let r=n.indexOf(s);r!==-1&&n.splice(r,1)}}async hook(t,...s){let n=this._hooks.get(t);if(n)for(let r of n)try{await r(...s)}catch(a){this.emit("error",new Error(`Error in hook handler for event "${t}": ${a.message}`))}}get hooks(){return this._hooks}getHooks(t){return this._hooks.get(t)}clearHooks(){this._hooks.clear()}};export{l as Eventified,m as Hookified}; | ||
//# sourceMappingURL=index.js.map |
@@ -145,3 +145,2 @@ type IEventEmitter = { | ||
}; | ||
type EventListener = (...arguments_: any[]) => void; | ||
@@ -148,0 +147,0 @@ declare class Eventified implements IEventEmitter { |
{ | ||
"name": "hookified", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"description": "Event and Middleware Hooks", | ||
@@ -60,8 +60,8 @@ "type": "module", | ||
"devDependencies": { | ||
"@vitest/coverage-v8": "^2.1.4", | ||
"docula": "^0.9.4", | ||
"@vitest/coverage-v8": "^2.1.5", | ||
"docula": "^0.9.5", | ||
"rimraf": "^6.0.1", | ||
"tsup": "^8.3.5", | ||
"typescript": "^5.6.3", | ||
"vitest": "^2.1.4", | ||
"typescript": "^5.7.2", | ||
"vitest": "^2.1.5", | ||
"xo": "^0.59.3" | ||
@@ -68,0 +68,0 @@ }, |
@@ -9,3 +9,3 @@ ![site/logo.svg](site/logo.svg) | ||
[![npm](https://img.shields.io/npm/dm/hookified)](https://npmjs.com/package/hookified) | ||
![jsDelivr hits](https://img.shields.io/jsdelivr/npm/hm/hookified) | ||
[![jsDelivr hits](https://img.shields.io/jsdelivr/npm/hm/hookified)](https://www.jsdelivr.com/package/npm/hookified) | ||
[![npm](https://img.shields.io/npm/v/hookified)](https://npmjs.com/package/hookified) | ||
@@ -12,0 +12,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
103179