events-ex 2.1.0 → 2.1.1

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [2.1.1](https://github.com/snowyu/events-ex.js/compare/v2.1.0...v2.1.1) (2025-10-24)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **ts:** forget to add removeListener declaration ([9c254b2](https://github.com/snowyu/events-ex.js/commit/9c254b2e1f1ab5e437c0099f002776a49e976c5b))
11
+
5
12
  ## [2.1.0](https://github.com/snowyu/events-ex.js/compare/v2.0.1...v2.1.0) (2025-06-09)
6
13
 
7
14
 
package/README.cn.md CHANGED
@@ -1,16 +1,7 @@
1
1
  ### events-ex [![npm](https://img.shields.io/npm/v/events-ex.svg)](https://npmjs.org/package/events-ex) [![downloads](https://img.shields.io/npm/dm/events-ex.svg)](https://npmjs.org/package/events-ex) [![license](https://img.shields.io/npm/l/events-ex.svg)](https://npmjs.org/package/events-ex)
2
2
 
3
-
4
3
  浏览器友好的增强的**事件**[能力][Ability]和类。 它主要是从 [event-emitter][event-emitter] 修改而来的。 本库可以为你的任何类添加(注入)**事件**[能力][Ability]。
5
4
 
6
-
7
- TODO: 异步事件,添加`emitAsync`方法. 没这么简单,因为要支持bubbling,所以必须顺序执行事件.
8
- 将`bubbling`作为功能选项.如果没有启用,就可以乱发了.
9
-
10
- 当关闭`bubbling`的时候,那么是否还需要用`event`对象传递.
11
-
12
- 首先完成异步支持.已经完成.`emitAsync`方法已经加上.
13
-
14
5
  ### Features
15
6
 
16
7
  * 重写核心架构
@@ -32,7 +23,7 @@ TODO: 异步事件,添加`emitAsync`方法. 没这么简单,因为要支持bubbl
32
23
  * **`改变`**: `emit` 方法返回监听器回调函数的结果而不是成功状态。
33
24
  * **`改变`**: 监听器回调函数的 `this` 对象是 `Event Object` 事件对象而不是事件发射器对象。
34
25
  * 事件发射器对象被放入 `Event` 对象的 `target` 属性中。
35
- * ⚡ 添加了`emitAsync`方法,确保所有异步监听器完成后再返回结果。
26
+ * ⚡ 添加了`emitAsync`方法,采用瀑布流式顺序执行异步事件,支持冒泡机制与中断。
36
27
  * 非常适合用于需要等待多个异步任务完成的场景(如数据验证、插件系统等)。
37
28
  * 事件监听器`on/once(event: string|RegExp, listener, index?:number)`
38
29
  * 📌 支持第三个参数 index(可选),允许你在监听器数组中指定插入位置。
@@ -110,7 +101,6 @@ my.emit('event1');
110
101
  import {EventEmitter, states} from 'events-ex';
111
102
  import {isObject} from 'util-ex';
112
103
 
113
- states.ABORT = -1
114
104
  class MyDb extends EventEmitter {
115
105
  get(key) {
116
106
  // Demo the event object bubbling usage:
package/README.md CHANGED
@@ -25,8 +25,8 @@ Browser-friendly enhanced event emitter [ability][Ability] and class. It's modif
25
25
  * The emitter object is put into the `target` property of the `Event` Object.
26
26
  * Adds async event emitting via `emitAsync` method.
27
27
  * ⚡ Added `emitAsync` Method:
28
- * Ensures all async listeners complete before returning results.
29
- * Ideal for scenarios requiring sequential async tasks (e.g., data validation, plugin systems).
28
+ * Ensures all async listeners are executed **sequentially** (in registration and bubbling order) before returning results.
29
+ * Ideal for scenarios requiring ordered async execution (e.g., middleware-style validation, plugin pipelines, state transitions).
30
30
  * Listener APIs: `on/once(event: string|RegExp, listener, index?: number)`
31
31
  * 📌 **Index Parameter** (Optional):
32
32
  * Allows specifying the insertion position in the listener array.
@@ -105,7 +105,6 @@ Bubbling event usage:
105
105
  import {EventEmitter, states} from 'events-ex';
106
106
  import {isObject} from 'util-ex';
107
107
 
108
- states.ABORT = -1
109
108
  class MyDb extends EventEmitter {
110
109
  get(key) {
111
110
  // Demo the event object bubbling usage:
package/docs/README.md CHANGED
@@ -27,8 +27,8 @@ Browser-friendly enhanced event emitter [ability][Ability] and class. It's modif
27
27
  * The emitter object is put into the `target` property of the `Event` Object.
28
28
  * Adds async event emitting via `emitAsync` method.
29
29
  * ⚡ Added `emitAsync` Method:
30
- * Ensures all async listeners complete before returning results.
31
- * Ideal for scenarios requiring sequential async tasks (e.g., data validation, plugin systems).
30
+ * Ensures all async listeners are executed **sequentially** (in registration and bubbling order) before returning results.
31
+ * Ideal for scenarios requiring ordered async execution (e.g., middleware-style validation, plugin pipelines, state transitions).
32
32
  * Listener APIs: `on/once(event: string|RegExp, listener, index?: number)`
33
33
  * 📌 **Index Parameter** (Optional):
34
34
  * Allows specifying the insertion position in the listener array.
@@ -106,7 +106,6 @@ Bubbling event usage:
106
106
  import {EventEmitter, states} from 'events-ex';
107
107
  import {isObject} from 'util-ex';
108
108
 
109
- states.ABORT = -1
110
109
  class MyDb extends EventEmitter {
111
110
  get(key) {
112
111
  // Demo the event object bubbling usage:
@@ -49,7 +49,7 @@ Event Object that contains information about the event, such as the target eleme
49
49
 
50
50
  #### Defined in
51
51
 
52
- [src/event.js:8](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event.js#L8)
52
+ [src/event.js:8](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event.js#L8)
53
53
 
54
54
  ## Properties
55
55
 
@@ -61,7 +61,7 @@ Keep your event result here if any.
61
61
 
62
62
  #### Defined in
63
63
 
64
- [src/event.js:38](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event.js#L38)
64
+ [src/event.js:38](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event.js#L38)
65
65
 
66
66
  ___
67
67
 
@@ -73,7 +73,7 @@ Whether stop the bubbling event
73
73
 
74
74
  #### Defined in
75
75
 
76
- [src/event.js:32](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event.js#L32)
76
+ [src/event.js:32](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event.js#L32)
77
77
 
78
78
  ___
79
79
 
@@ -85,7 +85,7 @@ Who trigger the event
85
85
 
86
86
  #### Defined in
87
87
 
88
- [src/event.js:26](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event.js#L26)
88
+ [src/event.js:26](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event.js#L26)
89
89
 
90
90
  ___
91
91
 
@@ -97,7 +97,7 @@ The type of the event.
97
97
 
98
98
  #### Defined in
99
99
 
100
- [src/event.js:44](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event.js#L44)
100
+ [src/event.js:44](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event.js#L44)
101
101
 
102
102
  ## Methods
103
103
 
@@ -115,7 +115,7 @@ The result of the event.
115
115
 
116
116
  #### Defined in
117
117
 
118
- [src/event.js:51](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event.js#L51)
118
+ [src/event.js:51](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event.js#L51)
119
119
 
120
120
  ___
121
121
 
@@ -138,4 +138,4 @@ Initializes the event with the target object.
138
138
 
139
139
  #### Defined in
140
140
 
141
- [src/event.js:20](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event.js#L20)
141
+ [src/event.js:20](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event.js#L20)
@@ -26,4 +26,4 @@ Class that represents an event emitter.
26
26
 
27
27
  #### Defined in
28
28
 
29
- [src/event-emitter.js:8](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event-emitter.js#L8)
29
+ [src/event-emitter.js:8](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event-emitter.js#L8)
@@ -26,6 +26,7 @@ Class that represents an event emitter.
26
26
  - [on](event_emitter.EventEmitter.md#on)
27
27
  - [once](event_emitter.EventEmitter.md#once)
28
28
  - [removeAllListeners](event_emitter.EventEmitter.md#removealllisteners)
29
+ - [removeListener](event_emitter.EventEmitter.md#removelistener)
29
30
  - [setMaxListeners](event_emitter.EventEmitter.md#setmaxlisteners)
30
31
  - [listenerCount](event_emitter.EventEmitter.md#listenercount-1)
31
32
 
@@ -47,7 +48,7 @@ Class that represents an event emitter.
47
48
 
48
49
  #### Defined in
49
50
 
50
- [src/event-emitter.d.ts:7](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event-emitter.d.ts#L7)
51
+ [src/event-emitter.d.ts:7](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event-emitter.d.ts#L7)
51
52
 
52
53
  ## Methods
53
54
 
@@ -72,7 +73,7 @@ The result of the event.
72
73
 
73
74
  #### Defined in
74
75
 
75
- [src/event-emitter.d.ts:38](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event-emitter.d.ts#L38)
76
+ [src/event-emitter.d.ts:48](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event-emitter.d.ts#L48)
76
77
 
77
78
  ___
78
79
 
@@ -97,7 +98,7 @@ A promise that resolves with the result of the event.
97
98
 
98
99
  #### Defined in
99
100
 
100
- [src/event-emitter.d.ts:44](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event-emitter.d.ts#L44)
101
+ [src/event-emitter.d.ts:54](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event-emitter.d.ts#L54)
101
102
 
102
103
  ___
103
104
 
@@ -121,7 +122,7 @@ Returns the count of listeners that are registered to listen for the specified e
121
122
 
122
123
  #### Defined in
123
124
 
124
- [src/event-emitter.d.ts:66](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event-emitter.d.ts#L66)
125
+ [src/event-emitter.d.ts:83](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event-emitter.d.ts#L83)
125
126
 
126
127
  ___
127
128
 
@@ -145,7 +146,7 @@ Returns an array of functions that are registered to listen for the specified ev
145
146
 
146
147
  #### Defined in
147
148
 
148
- [src/event-emitter.d.ts:59](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event-emitter.d.ts#L59)
149
+ [src/event-emitter.d.ts:76](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event-emitter.d.ts#L76)
149
150
 
150
151
  ___
151
152
 
@@ -172,9 +173,13 @@ The EventEmitter instance to allow chaining.
172
173
 
173
174
  If the listener is not a function.
174
175
 
176
+ **`See`**
177
+
178
+ [removeListener](event_emitter.EventEmitter.md#removelistener)
179
+
175
180
  #### Defined in
176
181
 
177
- [src/event-emitter.d.ts:32](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event-emitter.d.ts#L32)
182
+ [src/event-emitter.d.ts:33](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event-emitter.d.ts#L33)
178
183
 
179
184
  ___
180
185
 
@@ -203,7 +208,7 @@ If the listener is not a function.
203
208
 
204
209
  #### Defined in
205
210
 
206
- [src/event-emitter.d.ts:16](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event-emitter.d.ts#L16)
211
+ [src/event-emitter.d.ts:16](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event-emitter.d.ts#L16)
207
212
 
208
213
  ___
209
214
 
@@ -232,7 +237,7 @@ If the listener is not a function.
232
237
 
233
238
  #### Defined in
234
239
 
235
- [src/event-emitter.d.ts:24](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event-emitter.d.ts#L24)
240
+ [src/event-emitter.d.ts:24](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event-emitter.d.ts#L24)
236
241
 
237
242
  ___
238
243
 
@@ -256,7 +261,40 @@ Removes all listeners for a specific event or all events from an event emitter.
256
261
 
257
262
  #### Defined in
258
263
 
259
- [src/event-emitter.d.ts:51](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event-emitter.d.ts#L51)
264
+ [src/event-emitter.d.ts:61](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event-emitter.d.ts#L61)
265
+
266
+ ___
267
+
268
+ ### removeListener
269
+
270
+ ▸ **removeListener**(`eventName`, `listener`): [`EventEmitter`](event_emitter.EventEmitter.md)
271
+
272
+ Removes a listener function from the specified event type.
273
+
274
+ #### Parameters
275
+
276
+ | Name | Type | Description |
277
+ | :------ | :------ | :------ |
278
+ | `eventName` | `string` \| `RegExp` | - |
279
+ | `listener` | `Function` | The listener function to be removed. |
280
+
281
+ #### Returns
282
+
283
+ [`EventEmitter`](event_emitter.EventEmitter.md)
284
+
285
+ The EventEmitter instance to allow chaining.
286
+
287
+ **`Throws`**
288
+
289
+ If the listener is not a function.
290
+
291
+ **`See`**
292
+
293
+ [off](event_emitter.EventEmitter.md#off)
294
+
295
+ #### Defined in
296
+
297
+ [src/event-emitter.d.ts:42](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event-emitter.d.ts#L42)
260
298
 
261
299
  ___
262
300
 
@@ -264,19 +302,27 @@ ___
264
302
 
265
303
  ▸ **setMaxListeners**(`n`): [`EventEmitter`](event_emitter.EventEmitter.md)
266
304
 
305
+ Sets the maximum number of listeners allowed for the event emitter.
306
+
267
307
  #### Parameters
268
308
 
269
- | Name | Type |
270
- | :------ | :------ |
271
- | `n` | `number` |
309
+ | Name | Type | Description |
310
+ | :------ | :------ | :------ |
311
+ | `n` | `number` | The maximum number of listeners to set. Must be a positive integer. |
272
312
 
273
313
  #### Returns
274
314
 
275
315
  [`EventEmitter`](event_emitter.EventEmitter.md)
276
316
 
317
+ The [EventEmitter](event_emitter.EventEmitter.md) instance for method chaining.
318
+
319
+ **`Throws`**
320
+
321
+ If `n` is not a positive integer.
322
+
277
323
  #### Defined in
278
324
 
279
- [src/event-emitter.d.ts:52](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event-emitter.d.ts#L52)
325
+ [src/event-emitter.d.ts:69](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event-emitter.d.ts#L69)
280
326
 
281
327
  ___
282
328
 
@@ -303,4 +349,4 @@ use emitter.listenerCount instead
303
349
 
304
350
  #### Defined in
305
351
 
306
- [src/event-emitter.d.ts:74](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/event-emitter.d.ts#L74)
352
+ [src/event-emitter.d.ts:91](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/event-emitter.d.ts#L91)
@@ -41,4 +41,4 @@ Removes all listeners for a specific event or all events from an event emitter.
41
41
 
42
42
  #### Defined in
43
43
 
44
- [src/all-off.js:12](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/all-off.js#L12)
44
+ [src/all-off.js:12](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/all-off.js#L12)
@@ -17,7 +17,7 @@
17
17
 
18
18
  #### Defined in
19
19
 
20
- [src/consts.js:13](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/consts.js#L13)
20
+ [src/consts.js:13](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/consts.js#L13)
21
21
 
22
22
  ___
23
23
 
@@ -36,4 +36,4 @@ ___
36
36
 
37
37
  #### Defined in
38
38
 
39
- [src/consts.js:6](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/consts.js#L6)
39
+ [src/consts.js:6](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/consts.js#L6)
@@ -48,4 +48,4 @@ Renames and re-exports [getEventableMethods](default_methods.md#geteventablemeth
48
48
 
49
49
  #### Defined in
50
50
 
51
- [src/default-methods.js:14](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/default-methods.js#L14)
51
+ [src/default-methods.js:14](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/default-methods.js#L14)
@@ -46,4 +46,4 @@ Throws a TypeError if `obj` is null or undefined.
46
46
 
47
47
  #### Defined in
48
48
 
49
- [src/has-listeners.js:20](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/has-listeners.js#L20)
49
+ [src/has-listeners.js:20](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/has-listeners.js#L20)
@@ -46,4 +46,4 @@ Creates a pipeline between two event emitters, so that any events emitted by the
46
46
 
47
47
  #### Defined in
48
48
 
49
- [src/pipe.js:21](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/pipe.js#L21)
49
+ [src/pipe.js:21](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/pipe.js#L21)
@@ -46,4 +46,4 @@ Creates a pipeline between two event emitters, so that any events emitted by the
46
46
 
47
47
  #### Defined in
48
48
 
49
- [src/pipe-async.js:21](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/pipe-async.js#L21)
49
+ [src/pipe-async.js:21](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/pipe-async.js#L21)
@@ -43,4 +43,4 @@ Unifies the event listeners of two event emitter objects so that they share the
43
43
 
44
44
  #### Defined in
45
45
 
46
- [src/unify.js:17](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/unify.js#L17)
46
+ [src/unify.js:17](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/unify.js#L17)
@@ -36,4 +36,4 @@ Renames and re-exports [remove](util_array_remove.md#remove)
36
36
 
37
37
  #### Defined in
38
38
 
39
- [src/util/array-remove.js:5](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/util/array-remove.js#L5)
39
+ [src/util/array-remove.js:5](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/util/array-remove.js#L5)
@@ -38,4 +38,4 @@ Renames and re-exports [forEach](util_object_for_each.md#foreach)
38
38
 
39
39
  #### Defined in
40
40
 
41
- [src/util/object-for-each.js:6](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/util/object-for-each.js#L6)
41
+ [src/util/object-for-each.js:6](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/util/object-for-each.js#L6)
@@ -37,4 +37,4 @@ Renames and re-exports [pad](util_string_pad.md#pad)
37
37
 
38
38
  #### Defined in
39
39
 
40
- [src/util/string-pad.js:8](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/util/string-pad.js#L8)
40
+ [src/util/string-pad.js:8](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/util/string-pad.js#L8)
@@ -36,4 +36,4 @@ Renames and re-exports [toInt](util_to_int.md#toint)
36
36
 
37
37
  #### Defined in
38
38
 
39
- [src/util/to-int.js:2](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/util/to-int.js#L2)
39
+ [src/util/to-int.js:2](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/util/to-int.js#L2)
@@ -36,4 +36,4 @@ Renames and re-exports [validCallable](util_valid_callable.md#validcallable)
36
36
 
37
37
  #### Defined in
38
38
 
39
- [src/util/valid-callable.js:1](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/util/valid-callable.js#L1)
39
+ [src/util/valid-callable.js:1](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/util/valid-callable.js#L1)
@@ -36,4 +36,4 @@ Renames and re-exports [validObject](util_valid_object.md#validobject)
36
36
 
37
37
  #### Defined in
38
38
 
39
- [src/util/valid-object.js:3](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/util/valid-object.js#L3)
39
+ [src/util/valid-object.js:3](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/util/valid-object.js#L3)
@@ -30,7 +30,7 @@ Renames and re-exports [wrapEventEmitter](wrap_event_emitter.md#wrapeventemitter
30
30
 
31
31
  #### Defined in
32
32
 
33
- [src/wrap-event-emitter.js:7](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/wrap-event-emitter.js#L7)
33
+ [src/wrap-event-emitter.js:7](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/wrap-event-emitter.js#L7)
34
34
 
35
35
  ## Functions
36
36
 
@@ -54,4 +54,4 @@ o or new Event instance
54
54
 
55
55
  #### Defined in
56
56
 
57
- [src/wrap-event-emitter.js:34](https://github.com/snowyu/events-ex.js/blob/a6cce2d/src/wrap-event-emitter.js#L34)
57
+ [src/wrap-event-emitter.js:34](https://github.com/snowyu/events-ex.js/blob/9c254b2/src/wrap-event-emitter.js#L34)
@@ -28,8 +28,18 @@ export class EventEmitter {
28
28
  * @param {Function} listener - The listener function to be removed.
29
29
  * @returns {EventEmitter} The EventEmitter instance to allow chaining.
30
30
  * @throws {TypeError} If the listener is not a function.
31
+ * @see {@link removeListener}
31
32
  */
32
33
  off(eventName: string|RegExp, listener: ListenerCallbackFunc): EventEmitter;
34
+ /**
35
+ * Removes a listener function from the specified event type.
36
+ * @param {string|RegExp} type - The event type to remove the listener from.
37
+ * @param {Function} listener - The listener function to be removed.
38
+ * @returns {EventEmitter} The EventEmitter instance to allow chaining.
39
+ * @throws {TypeError} If the listener is not a function.
40
+ * @see {@link off}
41
+ */
42
+ removeListener(eventName: string|RegExp, listener: ListenerCallbackFunc): EventEmitter;
33
43
  /**
34
44
  * Emits the specified event type with the given arguments.
35
45
  * @param {...*} args - The event type followed by any number of arguments to be passed to the listener functions.
@@ -49,6 +59,13 @@ export class EventEmitter {
49
59
  * @returns {EventEmitter} - The event emitter with all listeners removed.
50
60
  */
51
61
  removeAllListeners(eventName?: string|RegExp): EventEmitter;
62
+ /**
63
+ * Sets the maximum number of listeners allowed for the event emitter.
64
+ *
65
+ * @param {number} n - The maximum number of listeners to set. Must be a positive integer.
66
+ * @returns {EventEmitter} The {@link EventEmitter} instance for method chaining.
67
+ * @throws {TypeError} If `n` is not a positive integer.
68
+ */
52
69
  setMaxListeners(n: number): EventEmitter;
53
70
  /**
54
71
  * Returns an array of functions that are registered to listen for the specified event.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "events-ex",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Browser-friendly enhanced events most compatible with standard node.js, it's powerful eventable ability.",
5
5
  "contributors": [
6
6
  {
@@ -28,8 +28,18 @@ export class EventEmitter {
28
28
  * @param {Function} listener - The listener function to be removed.
29
29
  * @returns {EventEmitter} The EventEmitter instance to allow chaining.
30
30
  * @throws {TypeError} If the listener is not a function.
31
+ * @see {@link removeListener}
31
32
  */
32
33
  off(eventName: string|RegExp, listener: ListenerCallbackFunc): EventEmitter;
34
+ /**
35
+ * Removes a listener function from the specified event type.
36
+ * @param {string|RegExp} type - The event type to remove the listener from.
37
+ * @param {Function} listener - The listener function to be removed.
38
+ * @returns {EventEmitter} The EventEmitter instance to allow chaining.
39
+ * @throws {TypeError} If the listener is not a function.
40
+ * @see {@link off}
41
+ */
42
+ removeListener(eventName: string|RegExp, listener: ListenerCallbackFunc): EventEmitter;
33
43
  /**
34
44
  * Emits the specified event type with the given arguments.
35
45
  * @param {...*} args - The event type followed by any number of arguments to be passed to the listener functions.
@@ -49,6 +59,13 @@ export class EventEmitter {
49
59
  * @returns {EventEmitter} - The event emitter with all listeners removed.
50
60
  */
51
61
  removeAllListeners(eventName?: string|RegExp): EventEmitter;
62
+ /**
63
+ * Sets the maximum number of listeners allowed for the event emitter.
64
+ *
65
+ * @param {number} n - The maximum number of listeners to set. Must be a positive integer.
66
+ * @returns {EventEmitter} The {@link EventEmitter} instance for method chaining.
67
+ * @throws {TypeError} If `n` is not a positive integer.
68
+ */
52
69
  setMaxListeners(n: number): EventEmitter;
53
70
  /**
54
71
  * Returns an array of functions that are registered to listen for the specified event.