@peter.naydenov/notice 2.0.0 → 2.1.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.
- package/Changelog.md +34 -0
- package/README.md +22 -31
- package/package.json +5 -1
- package/src/main.js +6 -0
- package/test/01-notice.js +14 -0
package/Changelog.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Release History
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### 2.1.0 ( 2023-07-17)
|
|
5
|
+
- [x] Method 'reset' was added. It removes all events and functions from the event emitter;
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### 2.0.0 ( 2023-06-15)
|
|
10
|
+
- [x] Library was converted to ES6 module;
|
|
11
|
+
- [x] License was changed from ISC to MIT;
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### 1.1.0 ( 2022-10-21)
|
|
16
|
+
- [x] Method 'debug' was added;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### 1.0.1 ( 2022-08-15)
|
|
22
|
+
- [x] Fix: Event data is coming in Array;
|
|
23
|
+
- [x] Fix: Multiple instances of notice;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### 1.0.0 (2021-05-12)
|
|
28
|
+
- [x] Initial code;
|
|
29
|
+
- [x] Test package;
|
|
30
|
+
- [x] Documentation;
|
|
31
|
+
- [ ] Bug: Event data is coming in Array;
|
|
32
|
+
- [ ] Bug: Multiple instances of notice;
|
|
33
|
+
|
|
34
|
+
|
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ eBus.emit ( 'note' )
|
|
|
35
35
|
on : 'Register a event'
|
|
36
36
|
, once : 'Register a single event'
|
|
37
37
|
, off : 'Unregister regular and single events'
|
|
38
|
+
, reset : 'Remove all events and functions from the event emitter' // After version 2.1.0
|
|
38
39
|
, emit : 'Trigger a event'
|
|
39
40
|
, stop : 'Ignore event for a while'
|
|
40
41
|
, start : 'Remove event from ignore list'
|
|
@@ -103,7 +104,25 @@ const
|
|
|
103
104
|
// ---> result == 5. Nothing changed
|
|
104
105
|
```
|
|
105
106
|
|
|
107
|
+
### Notice.reset ( )
|
|
108
|
+
Will remove all events and functions from the event emitter.
|
|
109
|
+
```js
|
|
110
|
+
let result = 0;
|
|
111
|
+
const
|
|
112
|
+
eBus = notice ()
|
|
113
|
+
, fn1 = () => result += 1
|
|
114
|
+
, fn2 = () => result += 3
|
|
115
|
+
, fn3 = () => result += 20
|
|
116
|
+
;
|
|
106
117
|
|
|
118
|
+
eBus.on ( 'go', fn1 )
|
|
119
|
+
eBus.on ( 'go', fn2 )
|
|
120
|
+
eBus.on ( 'load', fn3 )
|
|
121
|
+
eBus.reset () // Remove all events and functions
|
|
122
|
+
eBus.emit ( 'go' )
|
|
123
|
+
eBus.emit ( 'load' )
|
|
124
|
+
// ---> result == 0
|
|
125
|
+
```
|
|
107
126
|
|
|
108
127
|
|
|
109
128
|
### Notice.emit ( eventName, data )
|
|
@@ -191,38 +210,10 @@ eBus.emit ( 'dummy' )
|
|
|
191
210
|
|
|
192
211
|
|
|
193
212
|
|
|
213
|
+
## External Links
|
|
194
214
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
### 2.0.0 ( 2023-06-15)
|
|
201
|
-
- [x] Library was converted to ES6 module;
|
|
202
|
-
- [x] License was changed from ISC to MIT;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
### 1.1.0 ( 2022-10-21)
|
|
207
|
-
- [x] Method 'debug' was added;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
### 1.0.1 ( 2022-08-15)
|
|
213
|
-
- [x] Fix: Event data is coming in Array;
|
|
214
|
-
- [x] Fix: Multiple instances of notice;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
### 1.0.0 (2021-05-12)
|
|
219
|
-
- [x] Initial code;
|
|
220
|
-
- [x] Test package;
|
|
221
|
-
- [x] Documentation;
|
|
222
|
-
- [ ] Bug: Event data is coming in Array;
|
|
223
|
-
- [ ] Bug: Multiple instances of notice;
|
|
224
|
-
|
|
225
|
-
|
|
215
|
+
- [History of changes](https://github.com/PeterNaydenov/notice/Changelog.md)
|
|
216
|
+
- [MIT License](https://github.com/PeterNaydenov/notice/LICENSE)
|
|
226
217
|
|
|
227
218
|
|
|
228
219
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peter.naydenov/notice",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Event emmiter - NOTICE",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"type": "module",
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
"test": "mocha test",
|
|
9
9
|
"cover": "c8 mocha"
|
|
10
10
|
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/PeterNaydenov/notice"
|
|
14
|
+
},
|
|
11
15
|
"author": "Peter Naydenov",
|
|
12
16
|
"keywords": [
|
|
13
17
|
"events",
|
package/src/main.js
CHANGED
|
@@ -27,6 +27,11 @@ function notice () {
|
|
|
27
27
|
if ( scrollOnce[e] ) delete scrollOnce[e]
|
|
28
28
|
if ( scroll[e] ) delete scroll[e]
|
|
29
29
|
} // off func.
|
|
30
|
+
function reset () {
|
|
31
|
+
scroll = {}
|
|
32
|
+
scrollOnce = {}
|
|
33
|
+
ignore = []
|
|
34
|
+
} // reset func.
|
|
30
35
|
function debug ( val, header ) {
|
|
31
36
|
debugFlag = val ? true : false
|
|
32
37
|
if ( header && (typeof header === 'string') ) debugHeader = header
|
|
@@ -82,6 +87,7 @@ function notice () {
|
|
|
82
87
|
on // Register a event
|
|
83
88
|
, once // Register a single event
|
|
84
89
|
, off // Unregister regular and single events
|
|
90
|
+
, reset // Unregister all events
|
|
85
91
|
, emit // Trigger a event
|
|
86
92
|
, stop // Ignore event for a while
|
|
87
93
|
, start // Remove event from ignore list
|
package/test/01-notice.js
CHANGED
|
@@ -69,6 +69,20 @@ it ( 'Remove single event', () => {
|
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
|
|
72
|
+
it ( 'Reset the emitter', () => {
|
|
73
|
+
const eBus = notice ();
|
|
74
|
+
let result = 0;
|
|
75
|
+
|
|
76
|
+
eBus.once ( 'note', () => result += 1 )
|
|
77
|
+
eBus.on ( 'note', () => result += 3 )
|
|
78
|
+
eBus.on ( 'boom', () => result += 9 )
|
|
79
|
+
eBus.reset ()
|
|
80
|
+
eBus.emit ( 'note' )
|
|
81
|
+
eBus.emit ( 'boom' )
|
|
82
|
+
expect ( result ).to.be.equal ( 0 )
|
|
83
|
+
}) // it reset the emitter
|
|
84
|
+
|
|
85
|
+
|
|
72
86
|
it ( 'Stop and resume standard event', () => {
|
|
73
87
|
const eBus = notice ();
|
|
74
88
|
let result = 0;
|