@supercat1337/event-emitter 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
// version 1.0.3
|
|
2
|
+
|
|
1
3
|
// src/EventEmitter.js
|
|
2
4
|
var EventEmitter = class {
|
|
3
|
-
/** @type {Object.<string,
|
|
5
|
+
/** @type {Object.<string, Function[]>} */
|
|
4
6
|
events = {};
|
|
5
7
|
/**
|
|
6
8
|
* @param {string} event
|
|
7
|
-
* @param {
|
|
8
|
-
* @returns {
|
|
9
|
+
* @param {Function} listener
|
|
10
|
+
* @returns {()=>void}
|
|
9
11
|
*/
|
|
10
12
|
on(event, listener) {
|
|
11
13
|
if (typeof this.events[event] !== "object") {
|
|
@@ -20,7 +22,7 @@ var EventEmitter = class {
|
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* @param {string} event
|
|
23
|
-
* @param {
|
|
25
|
+
* @param {Function} listener
|
|
24
26
|
*/
|
|
25
27
|
removeListener(event, listener) {
|
|
26
28
|
var idx;
|
|
@@ -51,8 +53,8 @@ var EventEmitter = class {
|
|
|
51
53
|
}
|
|
52
54
|
/**
|
|
53
55
|
* @param {string} event
|
|
54
|
-
* @param {
|
|
55
|
-
* @returns {
|
|
56
|
+
* @param {Function} listener
|
|
57
|
+
* @returns {()=>void}
|
|
56
58
|
*/
|
|
57
59
|
once(event, listener) {
|
|
58
60
|
return this.on(event, function g() {
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
// version 1.0.3
|
|
1
2
|
var i=class{events={};on(e,s){typeof this.events[e]!="object"&&(this.events[e]=[]),this.events[e].push(s);let t=this;return function(){t.removeListener(e,s)}}removeListener(e,s){var t;typeof this.events[e]=="object"&&(t=this.events[e].indexOf(s),t>-1&&this.events[e].splice(t,1))}emit(e){if(typeof this.events[e]=="object"){var s,t,r,o=[].slice.call(arguments,1);for(t=this.events[e].slice(),r=t.length,s=0;s<r;s++)try{t[s].apply(this,o)}catch(n){console.error(e,o),console.error(n)}}}once(e,s){return this.on(e,function t(){this.removeListener(e,t),s.apply(this,arguments)})}};export{i as EventEmitter};
|
package/package.json
CHANGED
package/scripts/build.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
import * as esbuild from 'esbuild';
|
|
3
|
+
import * as esbuild from "./../node_modules/esbuild/lib/main.js";
|
|
7
4
|
|
|
8
5
|
import fs from 'fs';
|
|
9
6
|
|
|
@@ -69,7 +66,7 @@ async function main() {
|
|
|
69
66
|
minify: false,
|
|
70
67
|
outfile: filename_1,
|
|
71
68
|
platform: `neutral`,
|
|
72
|
-
|
|
69
|
+
banner: { "js": `// version ${packageInfo.version}` }
|
|
73
70
|
});
|
|
74
71
|
|
|
75
72
|
var filesize_1 = fs.statSync(filename_1).size;
|
|
@@ -81,7 +78,8 @@ async function main() {
|
|
|
81
78
|
bundle: true,
|
|
82
79
|
minify: true,
|
|
83
80
|
outfile: filename_2,
|
|
84
|
-
platform: `neutral
|
|
81
|
+
platform: `neutral`,
|
|
82
|
+
banner: { "js": `// version ${packageInfo.version}` }
|
|
85
83
|
});
|
|
86
84
|
|
|
87
85
|
|
package/src/EventEmitter.js
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {Function} TListener
|
|
5
|
-
* @typedef {()=>void} Unsubscriber
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @class
|
|
11
|
-
* */
|
|
12
3
|
class EventEmitter {
|
|
13
|
-
/** @type {Object.<string,
|
|
4
|
+
/** @type {Object.<string, Function[]>} */
|
|
14
5
|
events = {};
|
|
15
6
|
|
|
16
7
|
/**
|
|
17
8
|
* @param {string} event
|
|
18
|
-
* @param {
|
|
19
|
-
* @returns {
|
|
9
|
+
* @param {Function} listener
|
|
10
|
+
* @returns {()=>void}
|
|
20
11
|
*/
|
|
21
12
|
on(event, listener) {
|
|
22
13
|
|
|
@@ -36,7 +27,7 @@ class EventEmitter {
|
|
|
36
27
|
}
|
|
37
28
|
/**
|
|
38
29
|
* @param {string} event
|
|
39
|
-
* @param {
|
|
30
|
+
* @param {Function} listener
|
|
40
31
|
*/
|
|
41
32
|
removeListener(event, listener) {
|
|
42
33
|
var idx;
|
|
@@ -76,8 +67,8 @@ class EventEmitter {
|
|
|
76
67
|
|
|
77
68
|
/**
|
|
78
69
|
* @param {string} event
|
|
79
|
-
* @param {
|
|
80
|
-
* @returns {
|
|
70
|
+
* @param {Function} listener
|
|
71
|
+
* @returns {()=>void}
|
|
81
72
|
*/
|
|
82
73
|
once(event, listener) {
|
|
83
74
|
return this.on(event, function g() {
|