@akc42/app-utils 3.2.1 → 3.2.2
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/debug.js +9 -7
- package/package.json +1 -1
package/debug.js
CHANGED
|
@@ -74,22 +74,24 @@ function Debug (t) {
|
|
|
74
74
|
topic: tl,
|
|
75
75
|
timestamp: new Date().getTime(),
|
|
76
76
|
defined: false, //has the config been defined yet
|
|
77
|
-
enabled: false, //is this topic enabled
|
|
78
77
|
debug: async function (...args) {
|
|
79
78
|
//do time calc before potential delay to see if we are enabled
|
|
80
79
|
const now = new Date().getTime();
|
|
81
80
|
const gap = now - this.timestamp;
|
|
82
81
|
this.timestamp = now;
|
|
83
82
|
if (!this.defined) {
|
|
83
|
+
//just await the config the first time through. Thereafter we can assume its done
|
|
84
84
|
await config();
|
|
85
85
|
this.defined = true;
|
|
86
|
-
const debugConf = sessionStorage.getItem('debug');
|
|
87
|
-
if (debugConf) {
|
|
88
|
-
const topics = debugConf.split(':');
|
|
89
|
-
if (topics.includes(this.topic)) this.enabled = true;
|
|
90
|
-
}
|
|
91
86
|
}
|
|
92
|
-
|
|
87
|
+
let enabled = false;
|
|
88
|
+
const debugConf = sessionStorage.getItem('debug');
|
|
89
|
+
if (debugConf) {
|
|
90
|
+
const topics = debugConf.split(':');
|
|
91
|
+
if (topics.includes(this.topic)) enabled = true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (enabled) {
|
|
93
95
|
const message = args.reduce((cum, arg) => {
|
|
94
96
|
return `${cum} ${arg}`.trim();
|
|
95
97
|
}, '');
|