eventemitter3
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
declare class EventEmitter { | ||
declare class EventEmitter<EventTypes extends string | symbol = string | symbol> { | ||
static prefixed: string | boolean; | ||
@@ -13,3 +13,3 @@ | ||
*/ | ||
eventNames(): Array<string | symbol>; | ||
eventNames(): Array<EventTypes>; | ||
@@ -19,3 +19,3 @@ /** | ||
*/ | ||
listeners(event: string | symbol): Array<EventEmitter.ListenerFn>; | ||
listeners(event: EventTypes): Array<EventEmitter.ListenerFn>; | ||
@@ -25,3 +25,3 @@ /** | ||
*/ | ||
listenerCount(event: string | symbol): number; | ||
listenerCount(event: EventTypes): number; | ||
@@ -31,3 +31,3 @@ /** | ||
*/ | ||
emit(event: string | symbol, ...args: Array<any>): boolean; | ||
emit(event: EventTypes, ...args: Array<any>): boolean; | ||
@@ -37,4 +37,4 @@ /** | ||
*/ | ||
on(event: string | symbol, fn: EventEmitter.ListenerFn, context?: any): this; | ||
addListener(event: string | symbol, fn: EventEmitter.ListenerFn, context?: any): this; | ||
on(event: EventTypes, fn: EventEmitter.ListenerFn, context?: any): this; | ||
addListener(event: EventTypes, fn: EventEmitter.ListenerFn, context?: any): this; | ||
@@ -44,3 +44,3 @@ /** | ||
*/ | ||
once(event: string | symbol, fn: EventEmitter.ListenerFn, context?: any): this; | ||
once(event: EventTypes, fn: EventEmitter.ListenerFn, context?: any): this; | ||
@@ -50,4 +50,4 @@ /** | ||
*/ | ||
removeListener(event: string | symbol, fn?: EventEmitter.ListenerFn, context?: any, once?: boolean): this; | ||
off(event: string | symbol, fn?: EventEmitter.ListenerFn, context?: any, once?: boolean): this; | ||
removeListener(event: EventTypes, fn?: EventEmitter.ListenerFn, context?: any, once?: boolean): this; | ||
off(event: EventTypes, fn?: EventEmitter.ListenerFn, context?: any, once?: boolean): this; | ||
@@ -57,3 +57,3 @@ /** | ||
*/ | ||
removeAllListeners(event?: string | symbol): this; | ||
removeAllListeners(event?: EventTypes): this; | ||
} | ||
@@ -67,3 +67,3 @@ | ||
export interface EventEmitterStatic { | ||
new(): EventEmitter; | ||
new<EventTypes extends string | symbol = string | symbol>(): EventEmitter<EventTypes>; | ||
} | ||
@@ -70,0 +70,0 @@ |
{ | ||
"name": "eventemitter3", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "EventEmitter3 focuses on performance while maintaining a Node.js AND browser compatible interface.", | ||
@@ -8,7 +8,8 @@ "main": "index.js", | ||
"scripts": { | ||
"build": "mkdir -p umd && browserify index.js -s EventEmitter3 | uglifyjs -cm -o umd/eventemitter3.min.js", | ||
"browserify": "rm -rf umd && mkdir umd && browserify index.js -s EventEmitter3 -o umd/eventemitter3.js", | ||
"minify": "uglifyjs umd/eventemitter3.js --source-map -cm -o umd/eventemitter3.min.js", | ||
"benchmark": "find benchmarks/run -name '*.js' -exec benchmarks/start.sh {} \\;", | ||
"test": "nyc --reporter=html --reporter=text mocha test/test.js", | ||
"test-browser": "node test/browser.js", | ||
"prepublishOnly": "npm run build" | ||
"prepublishOnly": "npm run browserify && npm run minify", | ||
"test-browser": "node test/browser.js" | ||
}, | ||
@@ -48,7 +49,7 @@ "files": [ | ||
"assume": "~1.5.0", | ||
"browserify": "~15.2.0", | ||
"mocha": "~5.0.0", | ||
"nyc": "~11.4.1", | ||
"browserify": "~16.2.0", | ||
"mocha": "~5.1.0", | ||
"nyc": "~11.7.1", | ||
"pre-commit": "~1.2.0", | ||
"sauce-browsers": "~1.0.0", | ||
"sauce-browsers": "~1.2.0", | ||
"sauce-test": "~1.3.3", | ||
@@ -55,0 +56,0 @@ "uglify-js": "~3.3.0" |
@@ -1,1 +0,1 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).EventEmitter3=e()}}(function(){return function e(t,n,r){function o(s,f){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!f&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var a=n[s]={exports:{}};t[s][0].call(a.exports,function(e){var n=t[s][1][e];return o(n||e)},a,a.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(e,t,n){"use strict";var r=Object.prototype.hasOwnProperty,o="~";function i(){}function s(e,t,n,r,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new function(e,t,n){this.fn=e,this.context=t,this.once=n||!1}(n,r||e,i),f=o?o+t:t;return e._events[f]?e._events[f].fn?e._events[f]=[e._events[f],s]:e._events[f].push(s):(e._events[f]=s,e._eventsCount++),e}function f(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(o=!1)),c.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)r.call(e,t)&&n.push(o?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},c.prototype.listeners=function(e){var t=o?o+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,i=n.length,s=new Array(i);r<i;r++)s[r]=n[r].fn;return s},c.prototype.listenerCount=function(e){var t=o?o+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,r,i,s){var f=o?o+e:e;if(!this._events[f])return!1;var c,u,a=this._events[f],l=arguments.length;if(a.fn){switch(a.once&&this.removeListener(e,a.fn,void 0,!0),l){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,t),!0;case 3:return a.fn.call(a.context,t,n),!0;case 4:return a.fn.call(a.context,t,n,r),!0;case 5:return a.fn.call(a.context,t,n,r,i),!0;case 6:return a.fn.call(a.context,t,n,r,i,s),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];a.fn.apply(a.context,c)}else{var p,v=a.length;for(u=0;u<v;u++)switch(a[u].once&&this.removeListener(e,a[u].fn,void 0,!0),l){case 1:a[u].fn.call(a[u].context);break;case 2:a[u].fn.call(a[u].context,t);break;case 3:a[u].fn.call(a[u].context,t,n);break;case 4:a[u].fn.call(a[u].context,t,n,r);break;default:if(!c)for(p=1,c=new Array(l-1);p<l;p++)c[p-1]=arguments[p];a[u].fn.apply(a[u].context,c)}}return!0},c.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,r){var i=o?o+e:e;if(!this._events[i])return this;if(!t)return f(this,i),this;var s=this._events[i];if(s.fn)s.fn!==t||r&&!s.once||n&&s.context!==n||f(this,i);else{for(var c=0,u=[],a=s.length;c<a;c++)(s[c].fn!==t||r&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[i]=1===u.length?u[0]:u:f(this,i)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=o?o+e:e,this._events[t]&&f(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=o,c.EventEmitter=c,void 0!==t&&(t.exports=c)},{}]},{},[1])(1)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).EventEmitter3=e()}}(function(){return function i(s,f,c){function u(t,e){if(!f[t]){if(!s[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(a)return a(t,!0);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}var o=f[t]={exports:{}};s[t][0].call(o.exports,function(e){return u(s[t][1][e]||e)},o,o.exports,i,s,f,c)}return f[t].exports}for(var a="function"==typeof require&&require,e=0;e<c.length;e++)u(c[e]);return u}({1:[function(e,t,n){"use strict";var r=Object.prototype.hasOwnProperty,v="~";function o(){}function f(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,n,r,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var i=new f(n,r||e,o),s=v?v+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],i]:e._events[s].push(i):(e._events[s]=i,e._eventsCount++),e}function u(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function s(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(v=!1)),s.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)r.call(e,t)&&n.push(v?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},s.prototype.listeners=function(e){var t=v?v+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,o=n.length,i=new Array(o);r<o;r++)i[r]=n[r].fn;return i},s.prototype.listenerCount=function(e){var t=v?v+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,r,o,i){var s=v?v+e:e;if(!this._events[s])return!1;var f,c,u=this._events[s],a=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),a){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,r),!0;case 5:return u.fn.call(u.context,t,n,r,o),!0;case 6:return u.fn.call(u.context,t,n,r,o,i),!0}for(c=1,f=new Array(a-1);c<a;c++)f[c-1]=arguments[c];u.fn.apply(u.context,f)}else{var l,p=u.length;for(c=0;c<p;c++)switch(u[c].once&&this.removeListener(e,u[c].fn,void 0,!0),a){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,t);break;case 3:u[c].fn.call(u[c].context,t,n);break;case 4:u[c].fn.call(u[c].context,t,n,r);break;default:if(!f)for(l=1,f=new Array(a-1);l<a;l++)f[l-1]=arguments[l];u[c].fn.apply(u[c].context,f)}}return!0},s.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,n,r){var o=v?v+e:e;if(!this._events[o])return this;if(!t)return u(this,o),this;var i=this._events[o];if(i.fn)i.fn!==t||r&&!i.once||n&&i.context!==n||u(this,o);else{for(var s=0,f=[],c=i.length;s<c;s++)(i[s].fn!==t||r&&!i[s].once||n&&i[s].context!==n)&&f.push(i[s]);f.length?this._events[o]=1===f.length?f[0]:f:u(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=v?v+e:e,this._events[t]&&u(this,t)):(this._events=new o,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=v,s.EventEmitter=s,void 0!==t&&(t.exports=s)},{}]},{},[1])(1)}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36241
8
634
4