-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenabled.js
More file actions
25 lines (24 loc) · 788 Bytes
/
Copy pathenabled.js
File metadata and controls
25 lines (24 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const env = {
ERROR: process.env.ERROR,
WARN: process.env.WARN,
INFO: process.env.INFO,
DEBUG: process.env.DEBUG,
};
module.exports = (name, level) => {
const configs =
(globalThis.localStorage && globalThis.localStorage[level.toUpperCase()]) ||
env[level.toUpperCase()];
if (!configs) return false;
if (configs === "*") return true;
if (name === configs) return true;
const nameSegments = name.split(":");
return configs.split(",").some((subConfig) => {
if (name === subConfig) return true;
const configSegments = subConfig.split(":");
for (var i = 0; i < configSegments.length; i++) {
const configSegment = configSegments[i];
if (configSegment === "*") return true;
if (nameSegments[i] !== configSegment) break;
}
});
};