small-emitter
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -36,6 +36,6 @@ var __defProp = Object.defineProperty; | ||
const e = this.events; | ||
if (!e[name]) | ||
if (!((_a = e[name]) == null ? void 0 : _a.length)) | ||
return; | ||
const newCache = []; | ||
if (e[name] && callback) { | ||
if (callback) { | ||
const newCache = []; | ||
for (const item of e[name]) { | ||
@@ -46,4 +46,6 @@ if (item === callback || item._ === callback) | ||
} | ||
e[name] = newCache; | ||
} else { | ||
delete e[name]; | ||
} | ||
((_a = e[name]) == null ? void 0 : _a.length) ? e[name] = newCache : delete e[name]; | ||
} | ||
@@ -50,0 +52,0 @@ clear() { |
@@ -1,1 +0,1 @@ | ||
(function(s,i){typeof exports=="object"&&typeof module!="undefined"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(s=typeof globalThis!="undefined"?globalThis:s||self,i(s.emitter={}))})(this,function(s){"use strict";var c=Object.defineProperty;var h=(s,i,f)=>i in s?c(s,i,{enumerable:!0,configurable:!0,writable:!0,value:f}):s[i]=f;var d=(s,i,f)=>(h(s,typeof i!="symbol"?i+"":i,f),f);class i{constructor(){d(this,"events",{})}on(t,n){var o;const e=this.events;e[t]=e[t]||[],(o=e[t])==null||o.push(n)}once(t,n){const e=(...o)=>{this.off(t,e),n(...o)};return e._=n,this.on(t,e)}emit(t,...n){const e=this.events;if(!!e[t])for(const o of e[t])o(...n)}off(t,n){var r;const e=this.events;if(!e[t])return;const o=[];if(e[t]&&n)for(const u of e[t])u===n||u._===n||u&&o.push(u);(r=e[t])!=null&&r.length?e[t]=o:delete e[t]}clear(){this.events={}}}const f=()=>new i;s.Emitter=i,s.default=i,s.useEmitter=f,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
(function(s,e){typeof exports=="object"&&typeof module!="undefined"?e(exports):typeof define=="function"&&define.amd?define(["exports"],e):(s=typeof globalThis!="undefined"?globalThis:s||self,e(s.emitter={}))})(this,function(s){"use strict";var c=Object.defineProperty;var h=(s,e,f)=>e in s?c(s,e,{enumerable:!0,configurable:!0,writable:!0,value:f}):s[e]=f;var d=(s,e,f)=>(h(s,typeof e!="symbol"?e+"":e,f),f);class e{constructor(){d(this,"events",{})}on(i,n){var o;const t=this.events;t[i]=t[i]||[],(o=t[i])==null||o.push(n)}once(i,n){const t=(...o)=>{this.off(i,t),n(...o)};return t._=n,this.on(i,t)}emit(i,...n){const t=this.events;if(!!t[i])for(const o of t[i])o(...n)}off(i,n){var o;const t=this.events;if(!!((o=t[i])!=null&&o.length))if(n){const r=[];for(const u of t[i])u===n||u._===n||u&&r.push(u);t[i]=r}else delete t[i]}clear(){this.events={}}}const f=()=>new e;s.Emitter=e,s.default=e,s.useEmitter=f,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); |
{ | ||
"name": "small-emitter", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": "Lv Heng", |
75
10897