events-ex 2.0.0-alpha.7 → 2.0.0-alpha.8
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 +7 -0
- package/README.cn.md +1 -1
- package/README.md +1 -1
- package/docs/README.md +1 -1
- package/docs/classes/event.Event.md +6 -6
- package/docs/classes/event_emitter-1.EventEmitter.md +1 -1
- package/docs/classes/event_emitter.EventEmitter.md +11 -11
- package/docs/modules/all_off.md +1 -1
- package/docs/modules/consts.md +1 -1
- package/docs/modules/default_methods.md +1 -1
- package/docs/modules/has_listeners.md +1 -1
- package/docs/modules/pipe.md +1 -1
- package/docs/modules/pipe_async.md +1 -1
- package/docs/modules/unify.md +1 -1
- package/docs/modules/util_array_remove.md +1 -1
- package/docs/modules/util_object_for_each.md +1 -1
- package/docs/modules/util_string_pad.md +1 -1
- package/docs/modules/util_to_int.md +1 -1
- package/docs/modules/util_valid_callable.md +1 -1
- package/docs/modules/util_valid_object.md +1 -1
- package/docs/modules/wrap_event_emitter.md +2 -2
- package/lib/default-methods.js +3 -2
- package/package.json +1 -1
- package/src/default-methods.js +3 -3
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.0.0-alpha.8](https://github.com/snowyu/events-ex.js/compare/v2.0.0-alpha.7...v2.0.0-alpha.8) (2024-03-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* add eventName to the notify error event ([da3be72](https://github.com/snowyu/events-ex.js/commit/da3be7238689da19589e4d3a104d57b749d8a771))
|
|
11
|
+
|
|
5
12
|
## [2.0.0-alpha.7](https://github.com/snowyu/events-ex.js/compare/v2.0.0-alpha.6...v2.0.0-alpha.7) (2024-03-20)
|
|
6
13
|
|
|
7
14
|
|
package/README.cn.md
CHANGED
|
@@ -40,7 +40,7 @@ TODO: 异步事件,添加`emitAsync`方法. 没这么简单,因为要支持bubbl
|
|
|
40
40
|
* 添加了 `listenerCount()` 类方法,以保持与 Node 事件模块的兼容性。
|
|
41
41
|
* 添加了`emitAsync`方法,支持异步事件
|
|
42
42
|
|
|
43
|
-
注意: 时间内部引发错误不会中断通知,但是会在通知结束时 emit 错误事件(`emit('error', error, 'notify', listener, args)`)
|
|
43
|
+
注意: 时间内部引发错误不会中断通知,但是会在通知结束时 emit 错误事件(`emit('error', error, 'notify', eventName, listener, args)`)
|
|
44
44
|
|
|
45
45
|
### 安装
|
|
46
46
|
|
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ Browser-friendly enhanced event emitter [ability][Ability] and class. It's modif
|
|
|
31
31
|
+ Adds listenerCount() class method to keep compatibility with node events.
|
|
32
32
|
* Adds async event emitting via `emitAsync` method.
|
|
33
33
|
|
|
34
|
-
Note: The listener throw error should not broke the notification, but it will emit error(`emit('error', error, 'notify', listener, args)`) after notification.
|
|
34
|
+
Note: The listener throw error should not broke the notification, but it will emit error(`emit('error', error, 'notify', eventName, listener, args)`) after notification.
|
|
35
35
|
|
|
36
36
|
### Installation
|
|
37
37
|
|
package/docs/README.md
CHANGED
|
@@ -32,7 +32,7 @@ Browser-friendly enhanced event emitter [ability][Ability] and class. It's modif
|
|
|
32
32
|
+ Adds listenerCount() class method to keep compatibility with node events.
|
|
33
33
|
* Adds async event emitting via `emitAsync` method.
|
|
34
34
|
|
|
35
|
-
Note: The listener throw error should not broke the notification, but it will emit error(`emit('error', error, 'notify', listener, args)`) after notification.
|
|
35
|
+
Note: The listener throw error should not broke the notification, but it will emit error(`emit('error', error, 'notify', eventName, listener, args)`) after notification.
|
|
36
36
|
|
|
37
37
|
### Installation
|
|
38
38
|
|
|
@@ -47,7 +47,7 @@ Event Object that contains information about the event, such as the target eleme
|
|
|
47
47
|
|
|
48
48
|
#### Defined in
|
|
49
49
|
|
|
50
|
-
[src/event.js:8](https://github.com/snowyu/events-ex.js/blob/
|
|
50
|
+
[src/event.js:8](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event.js#L8)
|
|
51
51
|
|
|
52
52
|
## Properties
|
|
53
53
|
|
|
@@ -59,7 +59,7 @@ Keep your event result here if any.
|
|
|
59
59
|
|
|
60
60
|
#### Defined in
|
|
61
61
|
|
|
62
|
-
[src/event.js:38](https://github.com/snowyu/events-ex.js/blob/
|
|
62
|
+
[src/event.js:38](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event.js#L38)
|
|
63
63
|
|
|
64
64
|
___
|
|
65
65
|
|
|
@@ -71,7 +71,7 @@ Whether stop the bubbling event
|
|
|
71
71
|
|
|
72
72
|
#### Defined in
|
|
73
73
|
|
|
74
|
-
[src/event.js:32](https://github.com/snowyu/events-ex.js/blob/
|
|
74
|
+
[src/event.js:32](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event.js#L32)
|
|
75
75
|
|
|
76
76
|
___
|
|
77
77
|
|
|
@@ -83,7 +83,7 @@ Who trigger the event
|
|
|
83
83
|
|
|
84
84
|
#### Defined in
|
|
85
85
|
|
|
86
|
-
[src/event.js:26](https://github.com/snowyu/events-ex.js/blob/
|
|
86
|
+
[src/event.js:26](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event.js#L26)
|
|
87
87
|
|
|
88
88
|
## Methods
|
|
89
89
|
|
|
@@ -101,7 +101,7 @@ The result of the event.
|
|
|
101
101
|
|
|
102
102
|
#### Defined in
|
|
103
103
|
|
|
104
|
-
[src/event.js:45](https://github.com/snowyu/events-ex.js/blob/
|
|
104
|
+
[src/event.js:45](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event.js#L45)
|
|
105
105
|
|
|
106
106
|
___
|
|
107
107
|
|
|
@@ -123,4 +123,4 @@ Initializes the event with the target object.
|
|
|
123
123
|
|
|
124
124
|
#### Defined in
|
|
125
125
|
|
|
126
|
-
[src/event.js:20](https://github.com/snowyu/events-ex.js/blob/
|
|
126
|
+
[src/event.js:20](https://github.com/snowyu/events-ex.js/blob/da3be72/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:7](https://github.com/snowyu/events-ex.js/blob/
|
|
29
|
+
[src/event-emitter.js:7](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event-emitter.js#L7)
|
|
@@ -47,7 +47,7 @@ Class that represents an event emitter.
|
|
|
47
47
|
|
|
48
48
|
#### Defined in
|
|
49
49
|
|
|
50
|
-
[src/event-emitter.d.ts:7](https://github.com/snowyu/events-ex.js/blob/
|
|
50
|
+
[src/event-emitter.d.ts:7](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event-emitter.d.ts#L7)
|
|
51
51
|
|
|
52
52
|
## Methods
|
|
53
53
|
|
|
@@ -72,7 +72,7 @@ The result of the event.
|
|
|
72
72
|
|
|
73
73
|
#### Defined in
|
|
74
74
|
|
|
75
|
-
[src/event-emitter.d.ts:38](https://github.com/snowyu/events-ex.js/blob/
|
|
75
|
+
[src/event-emitter.d.ts:38](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event-emitter.d.ts#L38)
|
|
76
76
|
|
|
77
77
|
___
|
|
78
78
|
|
|
@@ -97,7 +97,7 @@ A promise that resolves with the result of the event.
|
|
|
97
97
|
|
|
98
98
|
#### Defined in
|
|
99
99
|
|
|
100
|
-
[src/event-emitter.d.ts:44](https://github.com/snowyu/events-ex.js/blob/
|
|
100
|
+
[src/event-emitter.d.ts:44](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event-emitter.d.ts#L44)
|
|
101
101
|
|
|
102
102
|
___
|
|
103
103
|
|
|
@@ -121,7 +121,7 @@ Returns the count of listeners that are registered to listen for the specified e
|
|
|
121
121
|
|
|
122
122
|
#### Defined in
|
|
123
123
|
|
|
124
|
-
[src/event-emitter.d.ts:66](https://github.com/snowyu/events-ex.js/blob/
|
|
124
|
+
[src/event-emitter.d.ts:66](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event-emitter.d.ts#L66)
|
|
125
125
|
|
|
126
126
|
___
|
|
127
127
|
|
|
@@ -145,7 +145,7 @@ Returns an array of functions that are registered to listen for the specified ev
|
|
|
145
145
|
|
|
146
146
|
#### Defined in
|
|
147
147
|
|
|
148
|
-
[src/event-emitter.d.ts:59](https://github.com/snowyu/events-ex.js/blob/
|
|
148
|
+
[src/event-emitter.d.ts:59](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event-emitter.d.ts#L59)
|
|
149
149
|
|
|
150
150
|
___
|
|
151
151
|
|
|
@@ -174,7 +174,7 @@ If the listener is not a function.
|
|
|
174
174
|
|
|
175
175
|
#### Defined in
|
|
176
176
|
|
|
177
|
-
[src/event-emitter.d.ts:32](https://github.com/snowyu/events-ex.js/blob/
|
|
177
|
+
[src/event-emitter.d.ts:32](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event-emitter.d.ts#L32)
|
|
178
178
|
|
|
179
179
|
___
|
|
180
180
|
|
|
@@ -203,7 +203,7 @@ If the listener is not a function.
|
|
|
203
203
|
|
|
204
204
|
#### Defined in
|
|
205
205
|
|
|
206
|
-
[src/event-emitter.d.ts:16](https://github.com/snowyu/events-ex.js/blob/
|
|
206
|
+
[src/event-emitter.d.ts:16](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event-emitter.d.ts#L16)
|
|
207
207
|
|
|
208
208
|
___
|
|
209
209
|
|
|
@@ -232,7 +232,7 @@ If the listener is not a function.
|
|
|
232
232
|
|
|
233
233
|
#### Defined in
|
|
234
234
|
|
|
235
|
-
[src/event-emitter.d.ts:24](https://github.com/snowyu/events-ex.js/blob/
|
|
235
|
+
[src/event-emitter.d.ts:24](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event-emitter.d.ts#L24)
|
|
236
236
|
|
|
237
237
|
___
|
|
238
238
|
|
|
@@ -256,7 +256,7 @@ Removes all listeners for a specific event or all events from an event emitter.
|
|
|
256
256
|
|
|
257
257
|
#### Defined in
|
|
258
258
|
|
|
259
|
-
[src/event-emitter.d.ts:51](https://github.com/snowyu/events-ex.js/blob/
|
|
259
|
+
[src/event-emitter.d.ts:51](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event-emitter.d.ts#L51)
|
|
260
260
|
|
|
261
261
|
___
|
|
262
262
|
|
|
@@ -276,7 +276,7 @@ ___
|
|
|
276
276
|
|
|
277
277
|
#### Defined in
|
|
278
278
|
|
|
279
|
-
[src/event-emitter.d.ts:52](https://github.com/snowyu/events-ex.js/blob/
|
|
279
|
+
[src/event-emitter.d.ts:52](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event-emitter.d.ts#L52)
|
|
280
280
|
|
|
281
281
|
___
|
|
282
282
|
|
|
@@ -297,4 +297,4 @@ ___
|
|
|
297
297
|
|
|
298
298
|
#### Defined in
|
|
299
299
|
|
|
300
|
-
[src/event-emitter.d.ts:67](https://github.com/snowyu/events-ex.js/blob/
|
|
300
|
+
[src/event-emitter.d.ts:67](https://github.com/snowyu/events-ex.js/blob/da3be72/src/event-emitter.d.ts#L67)
|
package/docs/modules/all_off.md
CHANGED
|
@@ -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/
|
|
44
|
+
[src/all-off.js:12](https://github.com/snowyu/events-ex.js/blob/da3be72/src/all-off.js#L12)
|
package/docs/modules/consts.md
CHANGED
|
@@ -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:8](https://github.com/snowyu/events-ex.js/blob/
|
|
51
|
+
[src/default-methods.js:8](https://github.com/snowyu/events-ex.js/blob/da3be72/src/default-methods.js#L8)
|
|
@@ -37,4 +37,4 @@ Renames and re-exports [hasListeners](has_listeners.md#haslisteners)
|
|
|
37
37
|
|
|
38
38
|
#### Defined in
|
|
39
39
|
|
|
40
|
-
[src/has-listeners.js:10](https://github.com/snowyu/events-ex.js/blob/
|
|
40
|
+
[src/has-listeners.js:10](https://github.com/snowyu/events-ex.js/blob/da3be72/src/has-listeners.js#L10)
|
package/docs/modules/pipe.md
CHANGED
|
@@ -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/
|
|
49
|
+
[src/pipe.js:21](https://github.com/snowyu/events-ex.js/blob/da3be72/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/
|
|
49
|
+
[src/pipe-async.js:21](https://github.com/snowyu/events-ex.js/blob/da3be72/src/pipe-async.js#L21)
|
package/docs/modules/unify.md
CHANGED
|
@@ -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/
|
|
46
|
+
[src/unify.js:17](https://github.com/snowyu/events-ex.js/blob/da3be72/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/
|
|
39
|
+
[src/util/array-remove.js:5](https://github.com/snowyu/events-ex.js/blob/da3be72/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/
|
|
41
|
+
[src/util/object-for-each.js:6](https://github.com/snowyu/events-ex.js/blob/da3be72/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/
|
|
40
|
+
[src/util/string-pad.js:8](https://github.com/snowyu/events-ex.js/blob/da3be72/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/
|
|
39
|
+
[src/util/to-int.js:2](https://github.com/snowyu/events-ex.js/blob/da3be72/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/
|
|
39
|
+
[src/util/valid-callable.js:1](https://github.com/snowyu/events-ex.js/blob/da3be72/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/
|
|
39
|
+
[src/util/valid-object.js:3](https://github.com/snowyu/events-ex.js/blob/da3be72/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:6](https://github.com/snowyu/events-ex.js/blob/
|
|
33
|
+
[src/wrap-event-emitter.js:6](https://github.com/snowyu/events-ex.js/blob/da3be72/src/wrap-event-emitter.js#L6)
|
|
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:33](https://github.com/snowyu/events-ex.js/blob/
|
|
57
|
+
[src/wrap-event-emitter.js:33](https://github.com/snowyu/events-ex.js/blob/da3be72/src/wrap-event-emitter.js#L33)
|
package/lib/default-methods.js
CHANGED
|
@@ -116,7 +116,7 @@ function getEventableMethods(aClass) {
|
|
|
116
116
|
if (errs.length) {
|
|
117
117
|
for (let i = 0; i < errs.length; i++) {
|
|
118
118
|
const it = errs[i];
|
|
119
|
-
this.emit('error', it.err, 'notify', it.listener, args);
|
|
119
|
+
this.emit('error', it.err, 'notify', r.type, it.listener, args);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
} finally {
|
|
@@ -156,7 +156,7 @@ function getEventableMethods(aClass) {
|
|
|
156
156
|
if (errs.length) {
|
|
157
157
|
for (let i = 0; i < errs.length; i++) {
|
|
158
158
|
const it = errs[i];
|
|
159
|
-
this.emit('error', it.err, 'notify', it.listener, args);
|
|
159
|
+
this.emit('error', it.err, 'notify', r.type, it.listener, args);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
} finally {
|
|
@@ -329,6 +329,7 @@ function _emit(type, msg) {
|
|
|
329
329
|
listeners = listeners.slice();
|
|
330
330
|
}
|
|
331
331
|
return {
|
|
332
|
+
type,
|
|
332
333
|
args,
|
|
333
334
|
listeners
|
|
334
335
|
};
|
package/package.json
CHANGED
package/src/default-methods.js
CHANGED
|
@@ -108,7 +108,7 @@ export function getEventableMethods(aClass) {
|
|
|
108
108
|
if (errs.length) {
|
|
109
109
|
for (let i=0;i<errs.length;i++) {
|
|
110
110
|
const it = errs[i]
|
|
111
|
-
this.emit('error', it.err, 'notify', it.listener, args)
|
|
111
|
+
this.emit('error', it.err, 'notify', r.type, it.listener, args)
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
} finally {
|
|
@@ -141,7 +141,7 @@ export function getEventableMethods(aClass) {
|
|
|
141
141
|
if (errs.length) {
|
|
142
142
|
for (let i=0;i<errs.length;i++) {
|
|
143
143
|
const it = errs[i]
|
|
144
|
-
this.emit('error', it.err, 'notify', it.listener, args)
|
|
144
|
+
this.emit('error', it.err, 'notify', r.type, it.listener, args)
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
} finally {
|
|
@@ -295,7 +295,7 @@ function _emit(type, msg) {
|
|
|
295
295
|
} else {
|
|
296
296
|
listeners = listeners.slice()
|
|
297
297
|
}
|
|
298
|
-
return {args, listeners}
|
|
298
|
+
return {type, args, listeners}
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
function _notify(listener, evt, args) {
|