@peter.naydenov/notice 2.3.0 → 2.3.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
@@ -1,9 +1,13 @@
1
1
  # Release History
2
2
 
3
3
 
4
+ ### 2.3.1 ( 2024-03-15 )
5
+ - [x] Fix: Callback stop should stop the wildcard callbacks as well;
6
+
7
+
4
8
  ### 2.3.0 ( 2024-03-14 )
5
9
  - [x] Stop execution of the event callbacks on first callback that returns string 'stop';
6
-
10
+ - [ ] Bug: Callback stop should stop the wildcard callbacks as well;
7
11
 
8
12
 
9
13
  ### 2.2.3 ( 2024-01-29)
package/README.md CHANGED
@@ -21,6 +21,7 @@ Use method '**stop**' to mute the event for a while. Use method '**start**' to u
21
21
  ## Last Updates
22
22
  - After version 2.1.0 Method 'reset' was added. It removes all events and functions from the event emitter;
23
23
  - After version 2.3.0 If callback that returns a string 'stop', the execution of followed callbacks will be stopped. Use this functionality to create a condition checking functions before your main callback if needed;
24
+ - In version 2.3.1 and above: Callback stop will stop the wildcard callbacks as well;
24
25
 
25
26
 
26
27
 
package/dist/notice.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";module.exports=function(){return new function(){let e={"*":[]},t={},n=[],o=!1,c="";return{on:function(t,n){e[t]||(e[t]=[]),e[t].push(n)},once:function(e,n){"*"!==e&&(t[e]||(t[e]=[]),t[e].push(n))},off:function(n,o){if(o)return e[n]&&(e[n]=e[n].filter((e=>e!==o))),t[n]&&(t[n]=t[n].filter((e=>e!==o))),e[n]&&0===e[n].length&&delete e[n],void(t[n]&&0===t[n].length&&delete e[n]);t[n]&&delete t[n],e[n]&&delete e[n]},reset:function(){e={"*":[]},t={},n=[]},emit:function(){const[s,...i]=arguments;function r(t){"*"!==t&&(n.includes(t)||(e[t].every((e=>{const t=e(...i);return"string"!=typeof t||"STOP"!==t.toUpperCase()})),e["*"].forEach((e=>e(s,...i)))))}if(o&&(console.log(`${c} Event "${s}" was triggered.`),i.length>0&&(console.log("Arguments:"),console.log(...i),console.log("^----"))),"*"!==s){if(t[s]){if(n.includes(s))return;t[s].forEach((e=>e(...i))),delete t[s]}e[s]&&r(s)}else{Object.keys(e).forEach((e=>r(e)))}},stop:function(o){if("*"!==o)n.push(o);else{const o=Object.keys(e),c=Object.keys(t);n=[...c,...o]}},start:function(e){n="*"!==e?n.filter((t=>e!=t)):[]},debug:function(e,t){o=!!e,t&&"string"==typeof t&&(c=t)}}}};
1
+ "use strict";module.exports=function(){return new function(){let e={"*":[]},t={},n=[],o=!1,c="";return{on:function(t,n){e[t]||(e[t]=[]),e[t].push(n)},once:function(e,n){"*"!==e&&(t[e]||(t[e]=[]),t[e].push(n))},off:function(n,o){if(o)return e[n]&&(e[n]=e[n].filter((e=>e!==o))),t[n]&&(t[n]=t[n].filter((e=>e!==o))),e[n]&&0===e[n].length&&delete e[n],void(t[n]&&0===t[n].length&&delete e[n]);t[n]&&delete t[n],e[n]&&delete e[n]},reset:function(){e={"*":[]},t={},n=[]},emit:function(){const[s,...i]=arguments;function r(t){let o=!1;"*"!==t&&(n.includes(t)||(e[t].every((e=>{const t=e(...i);return"string"!=typeof t||("STOP"!==t.toUpperCase()||(o=!0,!1))})),o||e["*"].forEach((e=>e(s,...i)))))}if(o&&(console.log(`${c} Event "${s}" was triggered.`),i.length>0&&(console.log("Arguments:"),console.log(...i),console.log("^----"))),"*"!==s){if(t[s]){if(n.includes(s))return;t[s].forEach((e=>e(...i))),delete t[s]}e[s]&&r(s)}else{Object.keys(e).forEach((e=>r(e)))}},stop:function(o){if("*"!==o)n.push(o);else{const o=Object.keys(e),c=Object.keys(t);n=[...c,...o]}},start:function(e){n="*"!==e?n.filter((t=>e!=t)):[]},debug:function(e,t){o=!!e,t&&"string"==typeof t&&(c=t)}}}};
@@ -1 +1 @@
1
- function e(){return new function(){let e={"*":[]},t={},n=[],o=!1,c="";return{on:function(t,n){e[t]||(e[t]=[]),e[t].push(n)},once:function(e,n){"*"!==e&&(t[e]||(t[e]=[]),t[e].push(n))},off:function(n,o){if(o)return e[n]&&(e[n]=e[n].filter((e=>e!==o))),t[n]&&(t[n]=t[n].filter((e=>e!==o))),e[n]&&0===e[n].length&&delete e[n],void(t[n]&&0===t[n].length&&delete e[n]);t[n]&&delete t[n],e[n]&&delete e[n]},reset:function(){e={"*":[]},t={},n=[]},emit:function(){const[f,...i]=arguments;function r(t){"*"!==t&&(n.includes(t)||(e[t].every((e=>{const t=e(...i);return"string"!=typeof t||"STOP"!==t.toUpperCase()})),e["*"].forEach((e=>e(f,...i)))))}if(o&&(console.log(`${c} Event "${f}" was triggered.`),i.length>0&&(console.log("Arguments:"),console.log(...i),console.log("^----"))),"*"!==f){if(t[f]){if(n.includes(f))return;t[f].forEach((e=>e(...i))),delete t[f]}e[f]&&r(f)}else{Object.keys(e).forEach((e=>r(e)))}},stop:function(o){if("*"!==o)n.push(o);else{const o=Object.keys(e),c=Object.keys(t);n=[...c,...o]}},start:function(e){n="*"!==e?n.filter((t=>e!=t)):[]},debug:function(e,t){o=!!e,t&&"string"==typeof t&&(c=t)}}}}export{e as default};
1
+ function e(){return new function(){let e={"*":[]},t={},n=[],o=!1,c="";return{on:function(t,n){e[t]||(e[t]=[]),e[t].push(n)},once:function(e,n){"*"!==e&&(t[e]||(t[e]=[]),t[e].push(n))},off:function(n,o){if(o)return e[n]&&(e[n]=e[n].filter((e=>e!==o))),t[n]&&(t[n]=t[n].filter((e=>e!==o))),e[n]&&0===e[n].length&&delete e[n],void(t[n]&&0===t[n].length&&delete e[n]);t[n]&&delete t[n],e[n]&&delete e[n]},reset:function(){e={"*":[]},t={},n=[]},emit:function(){const[f,...i]=arguments;function l(t){let o=!1;"*"!==t&&(n.includes(t)||(e[t].every((e=>{const t=e(...i);return"string"!=typeof t||("STOP"!==t.toUpperCase()||(o=!0,!1))})),o||e["*"].forEach((e=>e(f,...i)))))}if(o&&(console.log(`${c} Event "${f}" was triggered.`),i.length>0&&(console.log("Arguments:"),console.log(...i),console.log("^----"))),"*"!==f){if(t[f]){if(n.includes(f))return;t[f].forEach((e=>e(...i))),delete t[f]}e[f]&&l(f)}else{Object.keys(e).forEach((e=>l(e)))}},stop:function(o){if("*"!==o)n.push(o);else{const o=Object.keys(e),c=Object.keys(t);n=[...c,...o]}},start:function(e){n="*"!==e?n.filter((t=>e!=t)):[]},debug:function(e,t){o=!!e,t&&"string"==typeof t&&(c=t)}}}}export{e as default};
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).notice=t()}(this,(function(){"use strict";return function(){return new function(){let e={"*":[]},t={},n=[],o=!1,f="";return{on:function(t,n){e[t]||(e[t]=[]),e[t].push(n)},once:function(e,n){"*"!==e&&(t[e]||(t[e]=[]),t[e].push(n))},off:function(n,o){if(o)return e[n]&&(e[n]=e[n].filter((e=>e!==o))),t[n]&&(t[n]=t[n].filter((e=>e!==o))),e[n]&&0===e[n].length&&delete e[n],void(t[n]&&0===t[n].length&&delete e[n]);t[n]&&delete t[n],e[n]&&delete e[n]},reset:function(){e={"*":[]},t={},n=[]},emit:function(){const[i,...c]=arguments;function s(t){"*"!==t&&(n.includes(t)||(e[t].every((e=>{const t=e(...c);return"string"!=typeof t||"STOP"!==t.toUpperCase()})),e["*"].forEach((e=>e(i,...c)))))}if(o&&(console.log(`${f} Event "${i}" was triggered.`),c.length>0&&(console.log("Arguments:"),console.log(...c),console.log("^----"))),"*"!==i){if(t[i]){if(n.includes(i))return;t[i].forEach((e=>e(...c))),delete t[i]}e[i]&&s(i)}else{Object.keys(e).forEach((e=>s(e)))}},stop:function(o){if("*"!==o)n.push(o);else{const o=Object.keys(e),f=Object.keys(t);n=[...f,...o]}},start:function(e){n="*"!==e?n.filter((t=>e!=t)):[]},debug:function(e,t){o=!!e,t&&"string"==typeof t&&(f=t)}}}}}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).notice=t()}(this,(function(){"use strict";return function(){return new function(){let e={"*":[]},t={},n=[],o=!1,f="";return{on:function(t,n){e[t]||(e[t]=[]),e[t].push(n)},once:function(e,n){"*"!==e&&(t[e]||(t[e]=[]),t[e].push(n))},off:function(n,o){if(o)return e[n]&&(e[n]=e[n].filter((e=>e!==o))),t[n]&&(t[n]=t[n].filter((e=>e!==o))),e[n]&&0===e[n].length&&delete e[n],void(t[n]&&0===t[n].length&&delete e[n]);t[n]&&delete t[n],e[n]&&delete e[n]},reset:function(){e={"*":[]},t={},n=[]},emit:function(){const[i,...c]=arguments;function s(t){let o=!1;"*"!==t&&(n.includes(t)||(e[t].every((e=>{const t=e(...c);return"string"!=typeof t||("STOP"!==t.toUpperCase()||(o=!0,!1))})),o||e["*"].forEach((e=>e(i,...c)))))}if(o&&(console.log(`${f} Event "${i}" was triggered.`),c.length>0&&(console.log("Arguments:"),console.log(...c),console.log("^----"))),"*"!==i){if(t[i]){if(n.includes(i))return;t[i].forEach((e=>e(...c))),delete t[i]}e[i]&&s(i)}else{Object.keys(e).forEach((e=>s(e)))}},stop:function(o){if("*"!==o)n.push(o);else{const o=Object.keys(e),f=Object.keys(t);n=[...f,...o]}},start:function(e){n="*"!==e?n.filter((t=>e!=t)):[]},debug:function(e,t){o=!!e,t&&"string"==typeof t&&(f=t)}}}}}));
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.3.0",
4
+ "version": "2.3.1",
5
5
  "license": "MIT",
6
6
  "author": "Peter Naydenov",
7
7
  "main": "./dist/notice.umd.js",
package/src/main.js CHANGED
@@ -50,15 +50,19 @@ function notice () {
50
50
  }
51
51
 
52
52
  function exeCallback ( name ) {
53
+ let stopped = false;
53
54
  if ( name === '*' ) return
54
55
  if ( ignore.includes(name) ) return
55
56
  scroll[name].every ( fn => {
56
57
  const r = fn ( ...args );
57
58
  if ( typeof(r) !== 'string' ) return true
58
- if ( r.toUpperCase() === 'STOP' ) return false
59
+ if ( r.toUpperCase() === 'STOP' ) {
60
+ stopped = true
61
+ return false
62
+ }
59
63
  return true
60
64
  })
61
- scroll['*'].forEach ( fn => fn(e,...args) )
65
+ if ( !stopped ) scroll['*'].forEach ( fn => fn(e,...args) )
62
66
  } // exeCallback func.
63
67
 
64
68
  if ( e === '*' ) { // The wildcard '*' doesn't work for 'once' events