-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventilator.min.js
1 lines (1 loc) · 1.31 KB
/
eventilator.min.js
1
(a=>{const b=(a,c=a.length,...d)=>c<=d.length?a(...d):b.bind(null,a,c,...d),c=(b,e,f,g,h=!1)=>{function i(){g.call(this,...arguments,e),l.once&&l()}if("string"==typeof e&&(e=a.document.querySelectorAll(e),e=1===e.length?e[0]:Array.from(e)),Array.isArray(e)?!e.length:!e.addEventListener)throw new Error("nil/empty event target(s)");let j=null!=f&&f.constructor===Object;if(null==f||!(j||"string"==typeof f))throw new TypeError("cannot listen to nil or invalid event type");if(Array.isArray(e)){for(let a=0;a<e.length;a++)e[a]=c(b,e[a],j?Object.assign({},f):f,g,h);return e}if(j){for(const a in f)f[a]=c(b,e,a,f[a],h);return e.off=()=>{for(const a of e)a();return e},e.on=a=>{for(const b of e)b.on(a);return e},f}const k=a=>(null!=a&&a!==l.once&&(l.once=!!a),e.addEventListener(f,i,h),l.ison=!0,l),l=Object.assign(()=>(e.removeEventListener(f,i),l.ison=!1,l),{target:e,on:k,once:b,emit:d.emit.bind(e,e)});return l.off=l,k()},d=b(c,3);if(d.curry=b,d.once=c.bind(null,!0),d.on=c.bind(null,!1),d.emit=(b,c,d)=>{b.dispatchEvent(new a.CustomEvent(c,{detail:d}))},a.Proxy){const b={get:(a,b)=>(c,d,e)=>a(c,b,d,e)};d.once=new a.Proxy(d.once,b),d.on=new a.Proxy(d.on,b)}"undefined"==typeof module?a.define instanceof Function&&a.define.amd?a.define(["eventilator"],()=>d):a.eventilator=d:module.exports=d})("undefined"==typeof global?window:global);