-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubscribers.min.js
2 lines (2 loc) · 2.67 KB
/
subscribers.min.js
1
2
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).subscribers=e()}(this,(function(){"use strict";const t={},e=(t,e)=>{const r=Object.prototype.hasOwnProperty;return t&&r.call(t,e)},r=r=>e(t,r)&&t[r].length>0,n=(t,e=!0)=>e?r(t):(t=>{let e=r(t),n=t.lastIndexOf(".");for(;!e&&-1!==n;)n=(t=t.substring(0,n)).lastIndexOf("."),e=r(t);return e})(t),o=(e,o,c=!0)=>{const l=e=>{if(!r(e))return!1;t[e].forEach((t=>{const e=(t=>{const e=Object.prototype.toString;return["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]","[object BigInt64Array]","[object BigUint64Array]"].indexOf(e.call(t))>-1})(o)?o.toString():o;t.callback.call(t.context||t,e)}))},s=()=>{let t=e,r=e.lastIndexOf(".");for(;-1!==r;)t=t.substring(0,r),r=t.lastIndexOf("."),l(t);l(e),l("*")};if(!n(e))return!1;c?setTimeout(s,10):s()},c=(()=>{let t=0;return(e="guid-")=>(t+=1,`${e+t}`)})(),l=(e,r,n=null)=>{const o=c();let l="symbol"==typeof e?e.toString():e;return s=r,"[object Function]"===Object.prototype.toString.apply(s)&&(t[l]||(t[l]=[]),t[l].push({topic:l,callback:r,context:n,token:o}),o);var s},s=r=>{if(!e(t,r))return!1;delete t[r]},i=(e,r)=>{if(!n(e))return!1;r?(e=>{const r=Object.keys(t);if(!e||r.length<1)return!1;r.forEach((r=>{const n=t[r];let o;n.forEach(((t,r)=>{t.callback!==e&&t.token!==e||(o=t.topic,n.splice(-1,r))})),n.length<1&&s(o)}))})(r):s(e)},a=(t,e,r=null)=>l(t,(function(){i(t,e),e.apply(r||this,arguments)})),u=t=>"string"==typeof t,f=r=>{(t=>{const e=Object.prototype.toString;return Array.isArray?Array.isArray(t):"[object Array]"===e.apply(t)})(r)?(r=>{const o=Object.keys;if(!n(r)||o.length<1)return!1;o(t).forEach((n=>{e(t,n)&&n.startsWith(r)&&delete t[n]}))})(r):u(r)&&s(r)},y=r=>{return Object.keys(t).length<1?[]:r?u(n=r)&&/^guid-\d+$/i.test(n)?(e=>{const r=Object.keys(t);let n=null;return r.length<1?null:(t.forEach((t=>{t.forEach((r=>{r.callback!==e&&r.token!==e||(n=t)}))})),n)})(r):u(r)?(r=>{const n=Object.keys(t);let o=[];return n.length<1||n.forEach((n=>{const c={};e(t,n)&&n.startsWith(r)&&(c[n]=t[n],o.push(c))})),o})(r):void 0:t;var n};return{emit(t,e,r=!0){return o(t,e,r),this},notify(t,e){return((t,e)=>{o(t,e,!1)})(t,e),this},on:(t,e)=>l(t,e),once:(t,e)=>a(t,e),all:t=>(t=>l("*",t))(t),off(t,e){return i(t,e),this},remove(t){return f(t),this},clear(){return(()=>{const e=Object.keys(t);if(e.length<1)return!1;e.forEach((e=>{delete t[e]}))})(),this},get:t=>y(t),has:(t,e=!0)=>n(t,e)}}));
//# sourceMappingURL=subscribers.min.js.map