@peter.naydenov/notice 2.4.3 → 2.4.4

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.
@@ -3,7 +3,8 @@
3
3
  "allow": [
4
4
  "Bash(npx vitest *)",
5
5
  "Bash(node /private/tmp/claude-501/-Users-peternaydenov-Open-source-git-notice/5d42d1c1-e618-4ec6-8e58-148aaf476764/scratchpad/repro.mjs)",
6
- "Bash(node /private/tmp/claude-501/-Users-peternaydenov-Open-source-git-notice/5d42d1c1-e618-4ec6-8e58-148aaf476764/scratchpad/repro2.mjs)"
6
+ "Bash(node /private/tmp/claude-501/-Users-peternaydenov-Open-source-git-notice/5d42d1c1-e618-4ec6-8e58-148aaf476764/scratchpad/repro2.mjs)",
7
+ "Bash(node /private/tmp/claude-501/-Users-peternaydenov-Open-source-git-notice/5d42d1c1-e618-4ec6-8e58-148aaf476764/scratchpad/repro3.mjs)"
7
8
  ]
8
9
  }
9
10
  }
package/Changelog.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Release History
2
2
 
3
3
 
4
+ ### 2.4.4 ( 2026-07-07 )
5
+ - [x] Fix: Wildcard listeners are not notified for 'once' events;
6
+ - [x] Fix: Symbol events are invisible for wildcard 'emit' and 'stop';
7
+ - [x] Fix: Reserved object property names ( '__proto__', 'constructor' ) can not be used as event names;
8
+
9
+
10
+
4
11
  ### 2.4.3 ( 2026-07-07 )
5
12
  - [x] Fix: Removing the last 'once' subscriber with 'off' deletes the regular subscribers of the event;
6
13
  - [x] Fix: Removing the last wildcard listener breaks 'emit';
@@ -9,6 +16,7 @@
9
16
 
10
17
 
11
18
 
19
+
12
20
  ### 2.4.2 ( 2026-04-02 )
13
21
  - [x] Dependencies and devDependencies updates;
14
22
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@peter.naydenov/notice",
3
3
  "description": "Event emmiter - NOTICE",
4
- "version": "2.4.3",
4
+ "version": "2.4.4",
5
5
  "license": "MIT",
6
6
  "author": "Peter Naydenov",
7
7
  "main": "./src/main.js",
package/src/main.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict"
2
2
  function notice () {
3
3
 
4
- let
5
- scroll = {'*':[]} // General events with their subscribers
6
- , scrollOnce = {} // Single events with their subscribers
4
+ let
5
+ scroll = Object.assign ( Object.create(null), {'*':[]} ) // General events with their subscribers. Null prototype - event names like '__proto__' are safe
6
+ , scrollOnce = Object.create ( null ) // Single events with their subscribers
7
7
  , ignore = new Set () // Ignore event names ( general and single )
8
8
  , debugFlag = false
9
9
  , debugHeader = ''
@@ -55,8 +55,8 @@ function notice () {
55
55
  * Clears all general and single event subscriptions, as well as the ignore list.
56
56
  */
57
57
  function reset () {
58
- scroll = {'*':[]}
59
- scrollOnce = {}
58
+ scroll = Object.assign ( Object.create(null), {'*':[]} )
59
+ scrollOnce = Object.create ( null )
60
60
  ignore = new Set ()
61
61
  } // reset func.
62
62
  /**
@@ -106,7 +106,7 @@ function notice () {
106
106
  } // exeCallback func.
107
107
 
108
108
  if ( e === '*' ) { // The wildcard '*' doesn't work for 'once' events
109
- let evNames = Object.keys ( scroll )
109
+ let evNames = Reflect.ownKeys ( scroll ) // Reflect.ownKeys - event names can be Symbols
110
110
  evNames.forEach ( name => exeCallback(name) )
111
111
  return
112
112
  }
@@ -115,6 +115,7 @@ function notice () {
115
115
  const onceFns = scrollOnce[e]
116
116
  delete scrollOnce[e] // Delete before the calls, so handlers can re-register with 'once'
117
117
  onceFns.forEach ( fn => fn(...args) )
118
+ if ( !scroll[e] ) scroll['*'].forEach ( fn => fn(e,...args) ) // Notify wildcard listeners; if regular subscribers exist, 'exeCallback' will do it
118
119
  }
119
120
  if ( scroll[e] ) {
120
121
  exeCallback ( e )
@@ -141,9 +142,9 @@ function notice () {
141
142
  */
142
143
  function stop ( e ) {
143
144
  if ( e === '*' ) {
144
- const
145
- evNames = Object.keys ( scroll )
146
- , evOnceNames = Object.keys ( scrollOnce )
145
+ const
146
+ evNames = Reflect.ownKeys ( scroll ) // Reflect.ownKeys - event names can be Symbols
147
+ , evOnceNames = Reflect.ownKeys ( scrollOnce )
147
148
  ;
148
149
  ignore = new Set ([ ...evOnceNames, ...evNames ])
149
150
  return