-
Notifications
You must be signed in to change notification settings - Fork 1
/
event.min.js
3 lines (3 loc) · 1.58 KB
/
event.min.js
1
2
3
/*! lil-event - v0.1 - MIT License - https://github.com/lil-js/event */
(function(t,e){if(typeof define==="function"&&define.amd){define(["exports"],e)}else if(typeof exports==="object"){e(exports);if(typeof module==="object"&&module!==null){module.exports=exports.Event}}else{e(t.lil=t.lil||{})}})(this,function(t){"use strict";var e="0.1.3";var r=Array.prototype.slice;var n=Object.prototype.hasOwnProperty;function o(){}o.prototype.constructor=o;o.prototype.addListener=o.prototype.on=function(t,e,r){if(typeof t!=="string")throw new TypeError("First argument must be a string");if(typeof e!=="function")throw new TypeError("Second argument must be a function");if(!i.call(this,t,e)){s.call(this,t).push({fn:e,once:r||false})}return this};o.prototype.removeListener=o.prototype.off=function(t,e){var r;var n=s.call(this,t);var o=i.call(this,t,e);if(o){r=n.indexOf(o);if(r>=0)n.splice(r,1)}return this};o.prototype.addOnceListener=o.prototype.once=function(t,e,r){this.addListener(t,e,true);return this};o.prototype.emit=o.prototype.fire=function(t){var e,n,o,i=r.call(arguments,1);var f=s.call(this,t);if(t){for(e=0,n=f.length;e<n;e+=1){o=f[e];if(o.once)f.splice(e,1);o.fn.apply(null,i)}}return this};o.prototype.removeAllListeners=o.prototype.offAll=function(t){if(t&&n.call(this._events,t)){this._events[t].splice(0)}return this};function i(t,e){var r,n,o=s.call(this,t);for(r=0,n=o.length;r<n;r+=1){if(o[r].fn===e)return o[r]}}function s(t,e){var r=f.call(this);return n.call(r,t)?r[t]:r[t]=[]}function f(){return this._events||(this._events={})}o.VERSION=e;t.Event=o});
//# sourceMappingURL=event.min.js.map