events-ex 2.1.0 → 2.2.0

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.
Files changed (99) hide show
  1. package/.npmrcx +5 -0
  2. package/CHANGELOG.md +14 -0
  3. package/README.cn.md +112 -180
  4. package/README.md +133 -151
  5. package/docs/README.md +136 -150
  6. package/docs/all-off/README.md +17 -0
  7. package/docs/all-off/functions/allOff.md +33 -0
  8. package/docs/consts/README.md +12 -0
  9. package/docs/consts/variables/RegExpEventSymbol.md +11 -0
  10. package/docs/consts/variables/states.md +29 -0
  11. package/docs/default-methods/README.md +17 -0
  12. package/docs/default-methods/functions/getEventableMethods.md +301 -0
  13. package/docs/event/README.md +17 -0
  14. package/docs/event/classes/Event.md +143 -0
  15. package/docs/event-emitter/README-1.md +17 -0
  16. package/docs/event-emitter/README.md +17 -0
  17. package/docs/event-emitter/classes/EventEmitter-1.md +29 -0
  18. package/docs/event-emitter/classes/EventEmitter.md +349 -0
  19. package/docs/eventable/README.md +17 -0
  20. package/docs/eventable/functions/eventable.md +82 -0
  21. package/docs/has-listeners/README.md +17 -0
  22. package/docs/has-listeners/functions/hasListeners.md +38 -0
  23. package/docs/index/README.md +85 -0
  24. package/docs/modules.md +24 -23
  25. package/docs/pipe/README.md +17 -0
  26. package/docs/pipe/functions/pipe.md +41 -0
  27. package/docs/pipe-async/README.md +17 -0
  28. package/docs/pipe-async/functions/pipeAsync.md +41 -0
  29. package/docs/unify/README.md +17 -0
  30. package/docs/unify/functions/unify.md +35 -0
  31. package/docs/util/array-remove/README.md +17 -0
  32. package/docs/util/array-remove/functions/remove.md +21 -0
  33. package/docs/util/object-for-each/README.md +17 -0
  34. package/docs/util/object-for-each/functions/forEach.md +29 -0
  35. package/docs/util/promise-any/README.md +11 -0
  36. package/docs/util/promise-any/variables/default.md +9 -0
  37. package/docs/util/string-pad/README.md +17 -0
  38. package/docs/util/string-pad/functions/pad.md +25 -0
  39. package/docs/util/to-int/README.md +17 -0
  40. package/docs/util/to-int/functions/toInt.md +21 -0
  41. package/docs/util/valid-callable/README.md +17 -0
  42. package/docs/util/valid-callable/functions/validCallable.md +21 -0
  43. package/docs/util/valid-object/README.md +17 -0
  44. package/docs/util/valid-object/functions/validObject.md +21 -0
  45. package/docs/wrap-event-emitter/README.md +21 -0
  46. package/docs/wrap-event-emitter/functions/wrapEventEmitter.md +33 -0
  47. package/docs/wrap-event-emitter/variables/methods.md +11 -0
  48. package/lib/all-off.d.ts +1 -1
  49. package/lib/all-off.js +1 -1
  50. package/lib/default-methods.d.ts +28 -5
  51. package/lib/default-methods.js +114 -22
  52. package/lib/event-emitter.d.ts +17 -0
  53. package/lib/event.d.ts +9 -3
  54. package/lib/event.js +6 -0
  55. package/lib/eventable.js +4 -1
  56. package/lib/pipe-async.d.ts +4 -1
  57. package/lib/pipe-async.js +39 -5
  58. package/lib/pipe.d.ts +1 -1
  59. package/lib/pipe.js +1 -1
  60. package/lib/unify.d.ts +1 -1
  61. package/lib/unify.js +1 -1
  62. package/lib/util/array-remove.js +1 -1
  63. package/lib/util/object-for-each.js +1 -1
  64. package/lib/util/promise-any.d.ts +1 -0
  65. package/lib/util/promise-any.js +44 -0
  66. package/lib/util/string-pad.js +1 -1
  67. package/lib/wrap-event-emitter.d.ts +2 -1
  68. package/lib/wrap-event-emitter.js +24 -3
  69. package/package.json +17 -17
  70. package/src/default-methods.js +112 -15
  71. package/src/event-emitter.d.ts +17 -0
  72. package/src/event.js +6 -0
  73. package/src/eventable.js +3 -0
  74. package/src/pipe-async.js +64 -30
  75. package/src/util/promise-any.js +45 -0
  76. package/src/wrap-event-emitter.js +23 -18
  77. package/docs/.nojekyll +0 -1
  78. package/docs/classes/event.Event.md +0 -141
  79. package/docs/classes/event_emitter-1.EventEmitter.md +0 -29
  80. package/docs/classes/event_emitter.EventEmitter.md +0 -306
  81. package/docs/modules/all_off.md +0 -44
  82. package/docs/modules/consts.md +0 -39
  83. package/docs/modules/default_methods.md +0 -51
  84. package/docs/modules/event.md +0 -19
  85. package/docs/modules/event_emitter-1.md +0 -19
  86. package/docs/modules/event_emitter.md +0 -19
  87. package/docs/modules/eventable.md +0 -92
  88. package/docs/modules/has_listeners.md +0 -49
  89. package/docs/modules/index.md +0 -99
  90. package/docs/modules/pipe.md +0 -49
  91. package/docs/modules/pipe_async.md +0 -49
  92. package/docs/modules/unify.md +0 -46
  93. package/docs/modules/util_array_remove.md +0 -39
  94. package/docs/modules/util_object_for_each.md +0 -41
  95. package/docs/modules/util_string_pad.md +0 -40
  96. package/docs/modules/util_to_int.md +0 -39
  97. package/docs/modules/util_valid_callable.md +0 -39
  98. package/docs/modules/util_valid_object.md +0 -39
  99. package/docs/modules/wrap_event_emitter.md +0 -57
package/docs/README.md CHANGED
@@ -1,4 +1,6 @@
1
- events-ex / [Exports](modules.md)
1
+ **events-ex**
2
+
3
+ ***
2
4
 
3
5
  ### 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)
4
6
 
@@ -6,53 +8,57 @@ Browser-friendly enhanced event emitter [ability][Ability] and class. It's modif
6
8
 
7
9
  ### Features
8
10
 
9
- * Rewrite of the core architecture for improved performance and more powerful event-able ability
10
- * keep most compatible with [node events](nodejs.org/api/events.html) and [event-emitter][event-emitter]
11
- * Supports bubbling and interruption
12
- * Hook-able event system for more control over event handling
13
- * Supports async event emitting via `emitAsync` method which will wait for all async listeners to complete before returning.
14
- * Subscribe events with regular expression
11
+ * **Modular Event-able Ability**: Inject event capabilities into any class using `eventable(MyClass)` without forced inheritance.
12
+ * **Core Event Enhancements**:
13
+ * **Bubbling & Interruption**: Full support for event propagation and mid-stream cancellation.
14
+ * **Listener Ordering**: Precise control via the optional `index` parameter in `on()` and `once()`.
15
+ * **Regex Subscription**: Subscribe to multiple events using Regular Expressions.
16
+ * **Hook-able System**: Intercept and modify event behavior at the core level.
17
+ * **Advanced Asynchronous Features (Specific to `emitAsync`)**:
18
+ * **Configurable Concurrency**: Choose between **Serial** (default) and **Parallel** execution for async listeners.
19
+ * **Result Aggregation**: Strategies to gather return values: `last` (default), `first` (first success), and `collect` (all results).
20
+ * **Fluent API Proxies**: Use `.parallel()` and `.configure()` for transient, side-effect-free execution context.
21
+ * **Architecture**: Rewritten core for improved performance and flexibility while maintaining broad compatibility.
22
+ * **Event Utilities**: Built-in support for `pipe`, `pipeAsync`, `unify`, `allOff`, and `hasListeners`.
15
23
 
16
24
  ### Differences
17
25
 
18
- * Difference with [node events](https://nodejs.org/api/events.html)
26
+ * **Difference with [node events](https://nodejs.org/api/events.html)**
19
27
  + **`broken change`**: The event supports bubbling and interruption
20
28
  + the `event object` as listener's "this" object:
21
29
  * `result`: If set, the result is returned to the `Event Emitter`.
22
30
  * `stopped`: If set to `true`, it prevents the remaining listeners from being executed.
23
31
  * `target`: The `Event Emitter` object, which was originally the `this` object.
24
32
  * `type`: triggered event type(name).
33
+ * `resolved`: (Async only) Indicates if a successful result has been found in `first` mode.
25
34
  * **`broken change`**: The `emit` return the result of listeners's callback function instead of the successful state.
26
35
  * **`broken change`**: The `this` object of listeners' callback function is the `Event` Object instead of the emitter object.
27
36
  * The emitter object is put into the `target` property of the `Event` Object.
28
- * Adds async event emitting via `emitAsync` method.
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).
32
- * Listener APIs: `on/once(event: string|RegExp, listener, index?: number)`
33
- * 📌 **Index Parameter** (Optional):
34
- * Allows specifying the insertion position in the listener array.
35
- * Useful for precise control over listener execution order (e.g., pre-interception logic).
36
- * 🧪 **Regex Event Matching**:
37
- * Listeners can bind to multiple events via regex patterns.
38
- * Great for handling events with naming patterns (e.g., logs, state changes).
39
- * Difference with [event-emitter](https://github.com/medikoo/event-emitter)
40
- + **`broken change`**: The event supports bubbling and interruption(see above)
41
- + Adds the defaultMaxListeners class property to keep compatibility with node events.
42
- + Adds the setMaxListeners method to keep compatible with node events.
37
+ * **Enhanced `emitAsync` Method (Unique to Async)**:
38
+ * **Sequential (Serial)**: Executes listeners one-by-one, respecting `this.stopped`.
39
+ * **Concurrent (Parallel)**: Executes all listeners simultaneously.
40
+ * **Result Strategies**:
41
+ * `last`: Returns the result of the final listener (or last to finish).
42
+ * `first`: Returns the first successful non-undefined result (skips errors).
43
+ * `collect`: Returns an array of all results in registration order.
44
+ * **Fluent Configuration**: Use `.parallel()` or `.configure({...})` for one-time customized async emits.
45
+ * **Listener APIs**: `on/once(event: string|RegExp, listener, index?: number)`
46
+ * 📌 **Index Parameter** (Optional): Allows specifying the insertion position in the listener array.
47
+ * 🧪 **Regex Event Matching**: Listeners can bind to multiple events via regex patterns.
48
+
49
+ * **Difference with [event-emitter](https://github.com/medikoo/event-emitter)**
50
+ + **`broken change`**: The event supports bubbling and interruption (see above).
51
+ + Adds the `defaultMaxListeners` class property to keep compatibility with node events.
52
+ + Adds the `setMaxListeners` method to keep compatibility with node events.
43
53
  + Adds `error`, `newListener` and `removeListener` events to keep compatibility with node events.
44
- + Adds listeners() method to keep compatibility with node events.
45
- + Adds listenerCount() class method to keep compatibility with node events.
54
+ + Adds `listeners()` method to keep compatibility with node events.
55
+ + Adds `listenerCount()` class method to keep compatibility with node events.
46
56
  * Adds async event emitting via `emitAsync` method.
57
+
47
58
  * 🔗 **Event Piping & Unification**:
48
- * `pipe(source, target)`: Forwards events from one emitter to another.
49
- * `unify(emitter1, emitter2)`: Bi-directional event synchronization (e.g., shared state management).
50
- * 📦 **Utility Functions**:
51
- * Includes `allOff()`, `hasListeners()`, `listenerCount()` for debugging and lifecycle management.
52
- * Enhances robustness in event-driven architectures.
53
- * 🔌 **Modular Ability Injection**:
54
- * `eventable(MyClass)`: Inject event capabilities into any class without inheritance.
55
- * Configurable inclusion/exclusion of methods to avoid prototype pollution.
59
+ * `pipe(source, target)`: Sync event forwarding.
60
+ * `pipeAsync(source, target, options)`: Async forwarding with configurable concurrency and aggregation.
61
+ * `unify(emitter1, emitter2)`: Bi-directional synchronization.
56
62
 
57
63
  Note: The listener throw error should not broke the notification, but it will emit error(`emit('error', error, 'notify', eventName, listener, args)`) after notification.
58
64
 
@@ -64,7 +70,7 @@ npm install events-ex
64
70
 
65
71
  ### Usage
66
72
 
67
- Extends from `EventEmitter` class:
73
+ #### Extends from `EventEmitter` class
68
74
 
69
75
  ```js
70
76
  import {EventEmitter} from 'events-ex';
@@ -72,7 +78,7 @@ import {EventEmitter} from 'events-ex';
72
78
  class MyClass extends EventEmitter {}
73
79
  ```
74
80
 
75
- Add/Inject the event-able [ability][Ability] to your class directly:
81
+ #### Add/Inject the event-able [ability][Ability] to your class directly
76
82
 
77
83
  ```js
78
84
  import {eventable} from 'events-ex';
@@ -83,33 +89,39 @@ class MyClass extends MyRoot {}
83
89
  eventable(MyClass);
84
90
  ```
85
91
 
86
- Now, you can use events in your class:
92
+ #### Core Feature: Listener Ordering (Index Parameter)
87
93
 
88
94
  ```js
89
- const my = new MyClass;
95
+ const ee = new EventEmitter();
96
+ ee.on('test', () => console.log('second'), 1);
97
+ ee.on('test', () => console.log('first'), 0); // Insert at index 0
98
+
99
+ ee.emit('test');
100
+ // Output:
101
+ // first
102
+ // second
103
+ ```
90
104
 
91
- my.on('event', function() {
92
- console.log('event occur');
93
- });
105
+ #### Core Feature: Regex Subscription
94
106
 
95
- my.on(/^event/, function() {
96
- console.log('regexp match multi events');
107
+ ```js
108
+ const ee = new EventEmitter();
109
+ ee.on(/^user\..*/, function(data) {
110
+ console.log(`Event ${this.type} triggered with`, data);
97
111
  });
98
112
 
99
- my.emit('event');
100
- my.emit('event1');
113
+ ee.emit('user.login', { id: 1 });
114
+ ee.emit('user.logout', { id: 1 });
101
115
  ```
102
116
 
103
- Bubbling event usage:
117
+ #### Core Feature: Bubbling & Interruption
104
118
 
105
119
  ```js
106
120
  import {EventEmitter, states} from 'events-ex';
107
121
  import {isObject} from 'util-ex';
108
122
 
109
- states.ABORT = -1
110
123
  class MyDb extends EventEmitter {
111
124
  get(key) {
112
- // Demo the event object bubbling usage:
113
125
  let result = this.emit('getting', key)
114
126
  if(isObject(result)) {
115
127
  if (result.state === states.ABORT) return
@@ -121,149 +133,123 @@ class MyDb extends EventEmitter {
121
133
 
122
134
  let db = new MyDb
123
135
  db.on('getting', function(key){
124
- result = myGet(key);
136
+ let result = myGet(key);
125
137
  if (result != null) {
126
- // get the key succ
127
- this.result = {
128
- state: states.DONE,
129
- result: result,
130
- }
131
- this.stopped = true // it will skip other listeners if true
138
+ this.result = { state: states.DONE, result: result }
139
+ this.stopped = true // Skip remaining listeners
132
140
  } else {
133
- // you can abort to get key by default.
134
- this.result = {state: states.ABORT};
135
- // this.stopped = true // it will skip other listeners if true
141
+ this.result = { state: states.ABORT };
136
142
  }
137
143
  })
138
144
  ```
139
145
 
140
- event-emitter usage:
146
+ #### Async-Only Features: Concurrency & Aggregation
141
147
 
142
- ```javascript
148
+ These features apply **only** to the `emitAsync` method.
143
149
 
144
- import {wrapEventEmitter as ee} from 'events-ex';
150
+ ```js
151
+ const ee = new EventEmitter();
152
+ ee.on('task', async () => {
153
+ await sleep(100);
154
+ return 'result 1';
155
+ });
156
+ ee.on('task', async () => {
157
+ return 'result 2';
158
+ });
145
159
 
146
- class MyClass { /* .. */ };
147
- ee(MyClass.prototype); // All instances of MyClass will expose event-emitter interface
160
+ // 1. Default (Serial): Executes sequentially, returns 'result 2'
161
+ const res = await ee.emitAsync('task');
148
162
 
149
- const emitter = new MyClass();
150
- let listener;
163
+ // 2. Parallel + Collect: Executes concurrently, returns ['result 1', 'result 2']
164
+ const allResults = await ee.parallel('collect').emitAsync('task');
151
165
 
152
- emitter.on('test', listener = function (args) {
153
- // react to 'test' event
154
- });
166
+ // 3. Parallel + First: Executes concurrently, returns fastest success ('result 2')
167
+ const firstResult = await ee.parallel('first').emitAsync('task');
168
+ ```
155
169
 
156
- emitter.once('test', function (args) {
157
- // … react to first 'test' event (invoked only once!)
158
- });
170
+ ### Advanced Features
159
171
 
160
- emitter.emit('test', arg1, arg2/*…args*/); // Two above listeners invoked
161
- emitter.emit('test', arg1, arg2/*…args*/); // Only first listener invoked
172
+ #### Async Concurrency Engine (For `emitAsync` Only)
162
173
 
163
- emitter.off('test', listener); // Removed first listener
164
- emitter.emit('test', arg1, arg2/*…args*/); // No listeners invoked
165
- ```
174
+ | Option | Value | Description |
175
+ | :--- | :--- | :--- |
176
+ | **`asyncMode`** | `'serial'` | **(Default)** Listeners run one by one. Supports `this.stopped`. |
177
+ | | `'parallel'` | Listeners run concurrently. `this.stopped` is ignored. |
178
+ | **`resultMode`** | `'last'` | **(Default)** Returns the result of the last listener (or last to finish). |
179
+ | | `'first'` | Returns the first **non-undefined** and **successful** result. Skips errors. |
180
+ | | `'collect'` | Returns an array of all results in registration order. |
166
181
 
167
- ### API
182
+ #### Proxy Isolation (Fluent API)
168
183
 
169
- #### eventable(class[, options]) _(events-ex/eventable)_
184
+ Calling `.parallel()` or `.configure()` returns a transient Proxy Object (`Object.create(this)`), allowing thread-safe, isolated configurations for specific emits.
170
185
 
171
- Add the event-able ability to the class directly.
186
+ #### Safe Injection (AoP Compatibility) & Name Collisions
172
187
 
173
- * `class`: the class to be injected the ability.
174
- * `options` *(object)*: optional options
175
- * `include` *(string[]|string)*: only these emitter methods will be added to the class
176
- * **NOTE:** static method should use the prefix '@' with name.
177
- * `exclude` *(string[]|string)*: theses emitter methods would not be added to the class
178
- * **NOTE:** static method should use the prefix '@' with name.
179
- * `methods` *(object)*: hooked methods to the class
180
- * key: the method name to hook.
181
- * value: the new method function
182
- * use `this.super()` to call the original method.
183
- * `this.self` is the original `this` object.
184
- * `classMethods` *(object)*: hooked class methods to the class
188
+ When injecting event capabilities into an existing object or prototype via `wrapEventEmitter(target)` or `eventable(MyClass)`, a **minimal set** of methods is injected to minimize the risk of name collisions:
185
189
 
186
- ```js
187
- import {eventable} from 'events-ex'
190
+ - `on`, `once`, `off`
191
+ - `emit`, `emitAsync`
192
+ - `setEmitterOptions`
188
193
 
189
- class OtherClass {
190
- exec() {console.log "my original exec"}
191
- }
194
+ ⚠️ **Warning on Name Collisions**: If your target object already has methods with these names, they will be overwritten.
192
195
 
193
- class MyClass {}
194
- // only 'on', 'off', 'emit', 'emitAsync' and static methods 'listenerCount' added to the class
195
- eventable(MyClass, include: ['on', 'off', 'emit', 'emitAsync', '@listenerCount'])
196
-
197
- // add the eventable ability to OtherClass and inject the exec method of OtherClass.
198
- eventable(OtherClass, {methods: {
199
- exec() {
200
- console.log("new exec")
201
- this.super() //call the original method
202
- }}
203
- })
196
+ **Solution: Method Renaming**
197
+ You can use the `rename` option in `eventable` to map the emitter methods to custom names on your target:
198
+
199
+ ```js
200
+ eventable(MyClass, {
201
+ rename: {
202
+ emitAsync: 'myEmitAsync',
203
+ on: 'addListener'
204
+ }
205
+ });
206
+ // Now use: inst.myEmitAsync('event')
204
207
  ```
205
208
 
206
- #### allOff(obj) _(events-ex/all-off)_
209
+ **Full EventEmitter vs. Minimal Injection**
207
210
 
208
- **keep compatible only**: the `removeAllListeners` has already been buildin.
211
+ - **Standalone**: Calling `ee()` or `new EventEmitter()` without a target returns a **full instance** containing all advanced methods (including `.parallel()`, `.configure()`, `.setMaxListeners()`, etc.).
212
+ - **Injected**: Passing a target to `ee(target)` or using `eventable` performs a **minimal injection** to preserve the target's original footprint. Use `setEmitterOptions` on the target to access advanced async configurations.
209
213
 
210
- Removes all listeners from given event emitter object
214
+ ---
211
215
 
212
- #### hasListeners(obj[, name]) _(events-ex/has-listeners)_
216
+ ### API
217
+
218
+ #### eventable(class[, options]) _(events-ex/eventable)_
213
219
 
214
- Whether object has some listeners attached to the object.
215
- When `name` is provided, it checks listeners for specific event name
220
+ Add the event-able ability to the class directly.
221
+
222
+ * `class`: the class to be injected the ability.
223
+ * `options` _(object)_: optional options
224
+ * `include` _(string[]|string)_: only these emitter methods will be added to the class
225
+ * `exclude` _(string[]|string)_: theses emitter methods would not be added to the class
226
+ * `methods` _(object)_: hooked methods to the class
227
+ * `emitterOptions` _(object)_: default options for the emitter (e.g., `asyncMode`, `resultMode`).
228
+ * `rename` _(object)_: map the emitter methods to custom names on the class.
229
+ * key: original method name (e.g., 'on', 'emitAsync').
230
+ * value: new method name.
231
+
232
+ #### hasListeners(obj[, name]) _(events-ex/has-listeners)_
216
233
 
217
234
  ```javascript
218
- import {hasListeners, wrapEventEmitter as ee} from 'events-ex/has-listeners';
235
+ import {hasListeners, wrapEventEmitter as ee} from 'events-ex';
219
236
  var emitter = ee();
220
237
  var listener = function () {};
221
-
222
238
  hasListeners(emitter); // false
223
-
224
239
  emitter.on('foo', listener);
225
- hasListeners(emitter); // true
226
240
  hasListeners(emitter, 'foo'); // true
227
- hasListeners(emitter, 'bar'); // false
228
-
229
- emitter.off('foo', listener);
230
- hasListeners(emitter, 'foo'); // false
231
241
  ```
232
242
 
233
- #### pipe(source, target[, emitMethodName]) _(events-ex/pipe)_
234
-
235
- Pipes all events from _source_ emitter onto _target_ emitter (all events from _source_ emitter will be emitted also on _target_ emitter, but not other way).
236
- Returns _pipe_ object which exposes `pipe.close` function. Invoke it to close configured _pipe_.
237
- It works internally by redefinition of `emit` method, if in your interface this method is referenced differently, provide its name (or symbol) with third argument.
243
+ #### pipeAsync(source, target[, name, options]) _(events-ex/pipe-async)_
238
244
 
239
- #### unify(emitter1, emitter2) _(events-ex/unify)_
240
-
241
- Unifies event handling for two objects. Events emitted on _emitter1_ would be also emitter on _emitter2_, and other way back.
242
- Non reversible.
243
-
244
- ```javascript
245
- import {unify as eeUnify, wrapEventEmitter as ee} from 'events-ex';
245
+ Creates an asynchronous pipeline.
246
246
 
247
- var emitter1 = ee(), listener1, listener3;
248
- var emitter2 = ee(), listener2, listener4;
247
+ - `options.asyncMode`: Propagation mode (`'serial' | 'parallel'`).
248
+ - `options.resultMode`: Aggregation strategy.
249
249
 
250
- emitter1.on('test', listener1 = function () { });
251
- emitter2.on('test', listener2 = function () { });
250
+ #### setEmitterOptions(options)
252
251
 
253
- emitter1.emit('test'); // Invoked listener1
254
- emitter2.emit('test'); // Invoked listener2
255
-
256
- var unify = eeUnify(emitter1, emitter2);
257
-
258
- emitter1.emit('test'); // Invoked listener1 and listener2
259
- emitter2.emit('test'); // Invoked listener1 and listener2
260
-
261
- emitter1.on('test', listener3 = function () { });
262
- emitter2.on('test', listener4 = function () { });
263
-
264
- emitter1.emit('test'); // Invoked listener1, listener2, listener3 and listener4
265
- emitter2.emit('test'); // Invoked listener1, listener2, listener3 and listener4
266
- ```
252
+ Configures instance-wide defaults for `asyncMode`, `resultMode`, and `maxListeners`.
267
253
 
268
254
  [event-emitter]: https://github.com/medikoo/event-emitter
269
255
  [Ability]: https://github.com/snowyu/custom-ability.js
@@ -0,0 +1,17 @@
1
+ [**events-ex**](../README.md)
2
+
3
+ ***
4
+
5
+ [events-ex](../modules.md) / all-off
6
+
7
+ # all-off
8
+
9
+ ## Functions
10
+
11
+ - [allOff](functions/allOff.md)
12
+
13
+ ## References
14
+
15
+ ### default
16
+
17
+ Renames and re-exports [allOff](functions/allOff.md)
@@ -0,0 +1,33 @@
1
+ [**events-ex**](../../README.md)
2
+
3
+ ***
4
+
5
+ [events-ex](../../modules.md) / [all-off](../README.md) / allOff
6
+
7
+ # Function: allOff()
8
+
9
+ > **allOff**(`emitter`, `type?`): [`EventEmitter`](../../event-emitter/classes/EventEmitter.md)
10
+
11
+ Defined in: [src/all-off.js:12](https://github.com/snowyu/events-ex.js/blob/fb077063a0ea7231fa89bf74a09be2f52f8401e4/src/all-off.js#L12)
12
+
13
+ Removes all listeners for a specific event or all events from an event emitter.
14
+
15
+ ## Parameters
16
+
17
+ ### emitter
18
+
19
+ [`EventEmitter`](../../event-emitter/classes/EventEmitter.md)
20
+
21
+ The event emitter to remove listeners from.
22
+
23
+ ### type?
24
+
25
+ `string`
26
+
27
+ The event to remove listeners for. If not provided, all listeners for all events will be removed.
28
+
29
+ ## Returns
30
+
31
+ [`EventEmitter`](../../event-emitter/classes/EventEmitter.md)
32
+
33
+ - The event emitter with all listeners removed.
@@ -0,0 +1,12 @@
1
+ [**events-ex**](../README.md)
2
+
3
+ ***
4
+
5
+ [events-ex](../modules.md) / consts
6
+
7
+ # consts
8
+
9
+ ## Variables
10
+
11
+ - [RegExpEventSymbol](variables/RegExpEventSymbol.md)
12
+ - [states](variables/states.md)
@@ -0,0 +1,11 @@
1
+ [**events-ex**](../../README.md)
2
+
3
+ ***
4
+
5
+ [events-ex](../../modules.md) / [consts](../README.md) / RegExpEventSymbol
6
+
7
+ # Variable: RegExpEventSymbol
8
+
9
+ > `const` **RegExpEventSymbol**: `symbol` \| `"@@RegExpEvent"`
10
+
11
+ Defined in: [src/consts.js:13](https://github.com/snowyu/events-ex.js/blob/fb077063a0ea7231fa89bf74a09be2f52f8401e4/src/consts.js#L13)
@@ -0,0 +1,29 @@
1
+ [**events-ex**](../../README.md)
2
+
3
+ ***
4
+
5
+ [events-ex](../../modules.md) / [consts](../README.md) / states
6
+
7
+ # Variable: states
8
+
9
+ > `const` **states**: `object`
10
+
11
+ Defined in: [src/consts.js:6](https://github.com/snowyu/events-ex.js/blob/fb077063a0ea7231fa89bf74a09be2f52f8401e4/src/consts.js#L6)
12
+
13
+ ## Type Declaration
14
+
15
+ ### ABORT
16
+
17
+ > **ABORT**: `number`
18
+
19
+ ### CONTINUE
20
+
21
+ > **CONTINUE**: `any`
22
+
23
+ ### DONE
24
+
25
+ > **DONE**: `number`
26
+
27
+ ### STOPPED
28
+
29
+ > **STOPPED**: `number`
@@ -0,0 +1,17 @@
1
+ [**events-ex**](../README.md)
2
+
3
+ ***
4
+
5
+ [events-ex](../modules.md) / default-methods
6
+
7
+ # default-methods
8
+
9
+ ## Functions
10
+
11
+ - [getEventableMethods](functions/getEventableMethods.md)
12
+
13
+ ## References
14
+
15
+ ### default
16
+
17
+ Renames and re-exports [getEventableMethods](functions/getEventableMethods.md)