forked from chrisdavies/eev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eev.min.js
1 lines (1 loc) · 1.01 KB
/
eev.min.js
1
var Eev=function(){var t=0,e=/[\s,]+/g;function n(t){this.head=new i,this.tail=new i(this.head),this.head.next=this.tail,this.linkConstructor=t,this.reg={}}n.prototype={insert:function(t){var e=new i(this.tail.prev,this.tail,t);return e.next.prev=e.prev.next=e,e},remove:function(t){t.prev.next=t.next,t.next.prev=t.prev}};function i(t,e,n){this.prev=t,this.next=e,this.fn=n||r}i.prototype.run=function(t){this.fn(t),this.next&&this.next.run(t)};function r(){}function o(){this.events={}}return o.prototype={constructor:o,on:function(i,r){var o=this;i.split(e).forEach(function(e){var i=o.events[e]||(o.events[e]=new n),s=r._eev||(r._eev=++t);i.reg[s]||(i.reg[s]=i.insert(r))})},off:function(t,n){var i=this;n&&t.split(e).forEach(function(t){var e=i.events[t];if(e){var r=e.reg[n._eev];e.reg[n._eev]=void 0,e&&r&&e.remove(r)}})},emit:function(t,e){var n=this.events[t];n&&n.head.run(e)}},o}();!function(t,e){var n=t.define;n&&n.amd?n([],e):"undefined"!=typeof module&&module.exports&&(module.exports=e())}(this,function(){return Eev});