nightingale-debug 15.0.0 → 16.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 +22 -0
- package/README.md +10 -10
- package/lib/index.js +1 -0
- package/package.json +11 -53
- package/dist/definitions/index.d.ts +0 -5
- package/dist/definitions/index.d.ts.map +0 -1
- package/dist/definitions/index.test.d.ts +0 -2
- package/dist/definitions/index.test.d.ts.map +0 -1
- package/dist/index-browser.es.js +0 -74
- package/dist/index-browser.es.js.map +0 -1
- package/dist/index-node18.mjs +0 -74
- package/dist/index-node18.mjs.map +0 -1
- package/src/.eslintrc.json +0 -27
- package/src/index.test.ts +0 -50
- package/src/index.ts +0 -100
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [16.1.0](https://github.com/christophehurpeau/nightingale/compare/v16.0.0...v16.1.0) (2025-03-30)
|
|
7
|
+
|
|
8
|
+
Version bump for dependency: nightingale
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## [16.0.0](https://github.com/christophehurpeau/nightingale/compare/v15.0.0...v16.0.0) (2025-03-30)
|
|
12
|
+
|
|
13
|
+
### ⚠ BREAKING CHANGES
|
|
14
|
+
|
|
15
|
+
* drop node 18
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* drop node 18 ([1b11a55](https://github.com/christophehurpeau/nightingale/commit/1b11a55dd24c9435be50519a748316079f554414))
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* fix lib exports ([5b562b2](https://github.com/christophehurpeau/nightingale/commit/5b562b245aac1aa86b728a9433f3c9d28c62fe04))
|
|
24
|
+
|
|
25
|
+
Version bump for dependency: nightingale
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [15.0.0](https://github.com/christophehurpeau/nightingale/compare/v14.2.1...v15.0.0) (2023-12-25)
|
|
7
29
|
|
|
8
30
|
|
package/README.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
<
|
|
1
|
+
<h1 align="center">
|
|
2
2
|
nightingale-debug
|
|
3
|
-
</
|
|
3
|
+
</h1>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
|
|
6
|
+
Deprecated: use createFindDebugLevel from nightingale instead
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
|
-
<a href="https://npmjs.org/package/nightingale-debug"><img src="https://img.shields.io/npm/v/nightingale-debug.svg?style=flat-square"></a>
|
|
11
|
-
<a href="https://npmjs.org/package/nightingale-debug"><img src="https://img.shields.io/npm/dw/nightingale-debug.svg?style=flat-square"></a>
|
|
12
|
-
<a href="https://npmjs.org/package/nightingale-debug"><img src="https://img.shields.io/node/v/nightingale-debug.svg?style=flat-square"></a>
|
|
13
|
-
<a href="https://npmjs.org/package/nightingale-debug"><img src="https://img.shields.io/npm/types/nightingale-debug.svg?style=flat-square"></a>
|
|
10
|
+
<a href="https://npmjs.org/package/nightingale-debug"><img src="https://img.shields.io/npm/v/nightingale-debug.svg?style=flat-square" alt="npm version"></a>
|
|
11
|
+
<a href="https://npmjs.org/package/nightingale-debug"><img src="https://img.shields.io/npm/dw/nightingale-debug.svg?style=flat-square" alt="npm downloads"></a>
|
|
12
|
+
<a href="https://npmjs.org/package/nightingale-debug"><img src="https://img.shields.io/node/v/nightingale-debug.svg?style=flat-square" alt="node version"></a>
|
|
13
|
+
<a href="https://npmjs.org/package/nightingale-debug"><img src="https://img.shields.io/npm/types/nightingale-debug.svg?style=flat-square" alt="types"></a>
|
|
14
14
|
<a href="https://codecov.io/gh/christophehurpeau/nightingale"><img src="https://img.shields.io/codecov/c/github/christophehurpeau/nightingale/master.svg?style=flat-square"></a>
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
17
|
## Install
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
|
-
npm install --save nightingale
|
|
20
|
+
npm install --save nightingale
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## Used by:
|
|
24
24
|
|
|
25
|
-
-
|
|
26
|
-
-
|
|
25
|
+
- ConsoleHandler
|
|
26
|
+
- BrowserConsoleHandler
|
|
27
27
|
|
|
28
28
|
## Usage with nodejs
|
|
29
29
|
|
package/lib/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createFindDebugLevel } from "nightingale";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nightingale-debug",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "16.1.0",
|
|
4
|
+
"description": "Deprecated: use createFindDebugLevel from nightingale instead",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"logger"
|
|
7
7
|
],
|
|
@@ -15,70 +15,28 @@
|
|
|
15
15
|
"homepage": "https://github.com/christophehurpeau/nightingale",
|
|
16
16
|
"type": "module",
|
|
17
17
|
"engines": {
|
|
18
|
-
"node": ">=
|
|
18
|
+
"node": ">=20.9.0"
|
|
19
19
|
},
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"> 0.2%",
|
|
24
|
-
"not ie < 12",
|
|
25
|
-
"not safari < 10",
|
|
26
|
-
"not ios_saf < 10"
|
|
27
|
-
]
|
|
28
|
-
},
|
|
29
|
-
"main": "./dist/index-node18.mjs",
|
|
30
|
-
"types": "./dist/definitions/index.d.ts",
|
|
31
|
-
"module": "./dist/index-browser.es.js",
|
|
32
|
-
"browser": "./dist/index-browser.es.js",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"main": "./lib/index.js",
|
|
22
|
+
"types": "./lib/index.d.ts",
|
|
33
23
|
"exports": {
|
|
34
24
|
"./package.json": "./package.json",
|
|
35
|
-
".":
|
|
36
|
-
"types": "./dist/definitions/index.d.ts",
|
|
37
|
-
"node": {
|
|
38
|
-
"import": "./dist/index-node18.mjs"
|
|
39
|
-
},
|
|
40
|
-
"browser": {
|
|
41
|
-
"import": "./dist/index-browser.es.js"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
25
|
+
".": "./lib/index.js"
|
|
44
26
|
},
|
|
45
|
-
"sideEffects": false,
|
|
46
27
|
"files": [
|
|
47
|
-
"
|
|
48
|
-
"dist"
|
|
28
|
+
"lib"
|
|
49
29
|
],
|
|
50
30
|
"scripts": {
|
|
51
|
-
"build": "yarn clean:build && rollup --config rollup.config.mjs && yarn run build:definitions",
|
|
52
|
-
"build:definitions": "tsc -p tsconfig.json",
|
|
53
31
|
"clean": "yarn clean:build",
|
|
54
|
-
"clean:build": "pob-babel-clean-out dist",
|
|
55
32
|
"lint": "yarn run lint:eslint",
|
|
56
|
-
"lint:eslint": "yarn ../.. run eslint --
|
|
33
|
+
"lint:eslint": "yarn ../.. run eslint --quiet packages/nightingale-debug",
|
|
57
34
|
"test": "yarn ../../ run test -- packages/nightingale-debug",
|
|
58
35
|
"watch": "yarn clean:build && rollup --config rollup.config.mjs --watch"
|
|
59
36
|
},
|
|
37
|
+
"pob": {},
|
|
60
38
|
"prettier": "@pob/root/prettier-config",
|
|
61
|
-
"pob": {
|
|
62
|
-
"babelEnvs": [
|
|
63
|
-
{
|
|
64
|
-
"target": "node",
|
|
65
|
-
"version": "18"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"target": "browser"
|
|
69
|
-
}
|
|
70
|
-
],
|
|
71
|
-
"entries": [
|
|
72
|
-
"index"
|
|
73
|
-
]
|
|
74
|
-
},
|
|
75
39
|
"dependencies": {
|
|
76
|
-
"nightingale
|
|
77
|
-
},
|
|
78
|
-
"devDependencies": {
|
|
79
|
-
"@babel/core": "7.23.6",
|
|
80
|
-
"@babel/preset-env": "7.23.6",
|
|
81
|
-
"pob-babel": "38.0.0",
|
|
82
|
-
"typescript": "5.3.3"
|
|
40
|
+
"nightingale": "16.1.0"
|
|
83
41
|
}
|
|
84
42
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Level } from 'nightingale-levels';
|
|
2
|
-
export type DebugValueType = RegExp | string[] | string;
|
|
3
|
-
export type FindDebugLevel = (minLevel: Level, key: string) => Level;
|
|
4
|
-
export declare function createFindDebugLevel(debugValue?: DebugValueType): FindDebugLevel;
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAK3C,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;AAqBxD,MAAM,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,KAAK,CAAC;AAErE,wBAAgB,oBAAoB,CAClC,UAAU,CAAC,EAAE,cAAc,GAC1B,cAAc,CAoEhB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/index.test.ts"],"names":[],"mappings":""}
|
package/dist/index-browser.es.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Level } from 'nightingale-levels';
|
|
2
|
-
|
|
3
|
-
/* eslint-disable complexity */
|
|
4
|
-
const specialRegexpChars = /[$()+.?[\\\]^{|}]/;
|
|
5
|
-
const createTestFunctionFromRegexp = regexp => string => regexp.test(string);
|
|
6
|
-
const createTestFunctionFromRegexpString = value => {
|
|
7
|
-
if (!value.endsWith('/')) throw new Error('Invalid RegExp DEBUG value');
|
|
8
|
-
return createTestFunctionFromRegexp(new RegExp(value.slice(1, -1)));
|
|
9
|
-
};
|
|
10
|
-
const createTestFunctionFromValue = value => {
|
|
11
|
-
if (value.endsWith(':*')) {
|
|
12
|
-
value = value.slice(0, -2);
|
|
13
|
-
return string => string.startsWith(value);
|
|
14
|
-
}
|
|
15
|
-
return string => string === value;
|
|
16
|
-
};
|
|
17
|
-
function createFindDebugLevel(debugValue) {
|
|
18
|
-
let isWildcard = false;
|
|
19
|
-
const debugValues = [];
|
|
20
|
-
const skips = [];
|
|
21
|
-
if (!Array.isArray(debugValue)) {
|
|
22
|
-
if (debugValue instanceof RegExp) {
|
|
23
|
-
debugValues.push(createTestFunctionFromRegexp(debugValue));
|
|
24
|
-
debugValue = undefined;
|
|
25
|
-
} else if (debugValue) {
|
|
26
|
-
debugValue = debugValue.trim();
|
|
27
|
-
if (debugValue.startsWith('/')) {
|
|
28
|
-
debugValues.push(createTestFunctionFromRegexpString(debugValue));
|
|
29
|
-
debugValue = undefined;
|
|
30
|
-
} else {
|
|
31
|
-
debugValue = debugValue.split(/[\s,]+/);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (debugValue) {
|
|
36
|
-
debugValue.forEach(value => {
|
|
37
|
-
if (specialRegexpChars.test(value)) {
|
|
38
|
-
throw new Error(`Invalid debug value: "${value}" (contains special chars)`);
|
|
39
|
-
}
|
|
40
|
-
if (!value) return;
|
|
41
|
-
if (value === '*') {
|
|
42
|
-
isWildcard = true;
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (value.startsWith('-')) {
|
|
46
|
-
skips.push(createTestFunctionFromValue(value.slice(1)));
|
|
47
|
-
} else if (!isWildcard) {
|
|
48
|
-
debugValues.push(createTestFunctionFromValue(value));
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (isWildcard) {
|
|
53
|
-
if (skips.length === 0) {
|
|
54
|
-
return () => Level.ALL;
|
|
55
|
-
} else {
|
|
56
|
-
return (minLevel, key) => skips.some(skip => skip(key)) ? minLevel : Level.ALL;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (debugValues.length === 0) {
|
|
60
|
-
return minLevel => minLevel;
|
|
61
|
-
}
|
|
62
|
-
return (minLevel, key) => {
|
|
63
|
-
if (minLevel === Level.ALL || !key) {
|
|
64
|
-
return minLevel;
|
|
65
|
-
}
|
|
66
|
-
if (debugValues.some(dv => dv(key))) {
|
|
67
|
-
return skips.some(skip => skip(key)) ? minLevel : Level.ALL;
|
|
68
|
-
}
|
|
69
|
-
return minLevel;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export { createFindDebugLevel };
|
|
74
|
-
//# sourceMappingURL=index-browser.es.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-browser.es.js","sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable complexity */\nimport { Level } from 'nightingale-levels';\n\nconst specialRegexpChars = /[$()+.?[\\\\\\]^{|}]/;\n\ntype TestFunction = (string: string) => boolean;\nexport type DebugValueType = RegExp | string[] | string;\n\nconst createTestFunctionFromRegexp =\n (regexp: RegExp): TestFunction =>\n (string: string) =>\n regexp.test(string);\n\nconst createTestFunctionFromRegexpString = (value: string): TestFunction => {\n if (!value.endsWith('/')) throw new Error('Invalid RegExp DEBUG value');\n return createTestFunctionFromRegexp(new RegExp(value.slice(1, -1)));\n};\n\nconst createTestFunctionFromValue = (value: string): TestFunction => {\n if (value.endsWith(':*')) {\n value = value.slice(0, -2);\n return (string: string) => string.startsWith(value);\n }\n\n return (string: string) => string === value;\n};\n\nexport type FindDebugLevel = (minLevel: Level, key: string) => Level;\n\nexport function createFindDebugLevel(\n debugValue?: DebugValueType,\n): FindDebugLevel {\n let isWildcard = false;\n const debugValues: TestFunction[] = [];\n const skips: TestFunction[] = [];\n\n if (!Array.isArray(debugValue)) {\n if (debugValue instanceof RegExp) {\n debugValues.push(createTestFunctionFromRegexp(debugValue));\n debugValue = undefined;\n } else if (debugValue) {\n debugValue = debugValue.trim();\n\n if (debugValue.startsWith('/')) {\n debugValues.push(createTestFunctionFromRegexpString(debugValue));\n debugValue = undefined;\n } else {\n debugValue = debugValue.split(/[\\s,]+/);\n }\n }\n }\n\n if (debugValue) {\n (debugValue as string[]).forEach((value) => {\n if (specialRegexpChars.test(value)) {\n throw new Error(\n `Invalid debug value: \"${value}\" (contains special chars)`,\n );\n }\n\n if (!value) return;\n\n if (value === '*') {\n isWildcard = true;\n return;\n }\n\n if (value.startsWith('-')) {\n skips.push(createTestFunctionFromValue(value.slice(1)));\n } else if (!isWildcard) {\n debugValues.push(createTestFunctionFromValue(value));\n }\n });\n }\n\n if (isWildcard) {\n if (skips.length === 0) {\n return () => Level.ALL;\n } else {\n return (minLevel: Level, key: string) =>\n skips.some((skip) => skip(key)) ? minLevel : Level.ALL;\n }\n }\n\n if (debugValues.length === 0) {\n return (minLevel: Level) => minLevel;\n }\n\n return (minLevel: Level, key: string) => {\n if (minLevel === Level.ALL || !key) {\n return minLevel;\n }\n\n if (debugValues.some((dv) => dv(key))) {\n return skips.some((skip) => skip(key)) ? minLevel : Level.ALL;\n }\n\n return minLevel;\n };\n}\n"],"names":["specialRegexpChars","createTestFunctionFromRegexp","regexp","string","test","createTestFunctionFromRegexpString","value","endsWith","Error","RegExp","slice","createTestFunctionFromValue","startsWith","createFindDebugLevel","debugValue","isWildcard","debugValues","skips","Array","isArray","push","undefined","trim","split","forEach","length","Level","ALL","minLevel","key","some","skip","dv"],"mappings":";;AAAA;AAGA,MAAMA,kBAAkB,GAAG,mBAAmB,CAAA;AAK9C,MAAMC,4BAA4B,GAC/BC,MAAc,IACdC,MAAc,IACbD,MAAM,CAACE,IAAI,CAACD,MAAM,CAAC,CAAA;AAEvB,MAAME,kCAAkC,GAAIC,KAAa,IAAmB;AAC1E,EAAA,IAAI,CAACA,KAAK,CAACC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,IAAIC,KAAK,CAAC,4BAA4B,CAAC,CAAA;AACvE,EAAA,OAAOP,4BAA4B,CAAC,IAAIQ,MAAM,CAACH,KAAK,CAACI,KAAK,CAAC,CAAC,E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C,MAAA,OAAOD,QAAQ,CAAA;AACjB,KAAA;IAEA,IAAIZ,WAAW,CAACc,IAAI,CAAEE,EAAE,IAAKA,EAAE,CAACH,GAAG,CAAC,CAAC,EAAE;AACrC,MAAA,OAAOZ,KAAK,CAACa,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACF,GAAG,CAAC,CAAC,GAAGD,QAAQ,GAAGF,KAAK,CAACC,GAAG,CAAA;AAC/D,KAAA;AAEA,IAAA,OAAOC,QAAQ,CAAA;GAChB,CAAA;AACH;;;;"}
|
package/dist/index-node18.mjs
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Level } from 'nightingale-levels';
|
|
2
|
-
|
|
3
|
-
/* eslint-disable complexity */
|
|
4
|
-
const specialRegexpChars = /[$()+.?[\\\]^{|}]/;
|
|
5
|
-
const createTestFunctionFromRegexp = regexp => string => regexp.test(string);
|
|
6
|
-
const createTestFunctionFromRegexpString = value => {
|
|
7
|
-
if (!value.endsWith('/')) throw new Error('Invalid RegExp DEBUG value');
|
|
8
|
-
return createTestFunctionFromRegexp(new RegExp(value.slice(1, -1)));
|
|
9
|
-
};
|
|
10
|
-
const createTestFunctionFromValue = value => {
|
|
11
|
-
if (value.endsWith(':*')) {
|
|
12
|
-
value = value.slice(0, -2);
|
|
13
|
-
return string => string.startsWith(value);
|
|
14
|
-
}
|
|
15
|
-
return string => string === value;
|
|
16
|
-
};
|
|
17
|
-
function createFindDebugLevel(debugValue) {
|
|
18
|
-
let isWildcard = false;
|
|
19
|
-
const debugValues = [];
|
|
20
|
-
const skips = [];
|
|
21
|
-
if (!Array.isArray(debugValue)) {
|
|
22
|
-
if (debugValue instanceof RegExp) {
|
|
23
|
-
debugValues.push(createTestFunctionFromRegexp(debugValue));
|
|
24
|
-
debugValue = undefined;
|
|
25
|
-
} else if (debugValue) {
|
|
26
|
-
debugValue = debugValue.trim();
|
|
27
|
-
if (debugValue.startsWith('/')) {
|
|
28
|
-
debugValues.push(createTestFunctionFromRegexpString(debugValue));
|
|
29
|
-
debugValue = undefined;
|
|
30
|
-
} else {
|
|
31
|
-
debugValue = debugValue.split(/[\s,]+/);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (debugValue) {
|
|
36
|
-
debugValue.forEach(value => {
|
|
37
|
-
if (specialRegexpChars.test(value)) {
|
|
38
|
-
throw new Error(`Invalid debug value: "${value}" (contains special chars)`);
|
|
39
|
-
}
|
|
40
|
-
if (!value) return;
|
|
41
|
-
if (value === '*') {
|
|
42
|
-
isWildcard = true;
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (value.startsWith('-')) {
|
|
46
|
-
skips.push(createTestFunctionFromValue(value.slice(1)));
|
|
47
|
-
} else if (!isWildcard) {
|
|
48
|
-
debugValues.push(createTestFunctionFromValue(value));
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (isWildcard) {
|
|
53
|
-
if (skips.length === 0) {
|
|
54
|
-
return () => Level.ALL;
|
|
55
|
-
} else {
|
|
56
|
-
return (minLevel, key) => skips.some(skip => skip(key)) ? minLevel : Level.ALL;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (debugValues.length === 0) {
|
|
60
|
-
return minLevel => minLevel;
|
|
61
|
-
}
|
|
62
|
-
return (minLevel, key) => {
|
|
63
|
-
if (minLevel === Level.ALL || !key) {
|
|
64
|
-
return minLevel;
|
|
65
|
-
}
|
|
66
|
-
if (debugValues.some(dv => dv(key))) {
|
|
67
|
-
return skips.some(skip => skip(key)) ? minLevel : Level.ALL;
|
|
68
|
-
}
|
|
69
|
-
return minLevel;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export { createFindDebugLevel };
|
|
74
|
-
//# sourceMappingURL=index-node18.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-node18.mjs","sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable complexity */\nimport { Level } from 'nightingale-levels';\n\nconst specialRegexpChars = /[$()+.?[\\\\\\]^{|}]/;\n\ntype TestFunction = (string: string) => boolean;\nexport type DebugValueType = RegExp | string[] | string;\n\nconst createTestFunctionFromRegexp =\n (regexp: RegExp): TestFunction =>\n (string: string) =>\n regexp.test(string);\n\nconst createTestFunctionFromRegexpString = (value: string): TestFunction => {\n if (!value.endsWith('/')) throw new Error('Invalid RegExp DEBUG value');\n return createTestFunctionFromRegexp(new RegExp(value.slice(1, -1)));\n};\n\nconst createTestFunctionFromValue = (value: string): TestFunction => {\n if (value.endsWith(':*')) {\n value = value.slice(0, -2);\n return (string: string) => string.startsWith(value);\n }\n\n return (string: string) => string === value;\n};\n\nexport type FindDebugLevel = (minLevel: Level, key: string) => Level;\n\nexport function createFindDebugLevel(\n debugValue?: DebugValueType,\n): FindDebugLevel {\n let isWildcard = false;\n const debugValues: TestFunction[] = [];\n const skips: TestFunction[] = [];\n\n if (!Array.isArray(debugValue)) {\n if (debugValue instanceof RegExp) {\n debugValues.push(createTestFunctionFromRegexp(debugValue));\n debugValue = undefined;\n } else if (debugValue) {\n debugValue = debugValue.trim();\n\n if (debugValue.startsWith('/')) {\n debugValues.push(createTestFunctionFromRegexpString(debugValue));\n debugValue = undefined;\n } else {\n debugValue = debugValue.split(/[\\s,]+/);\n }\n }\n }\n\n if (debugValue) {\n (debugValue as string[]).forEach((value) => {\n if (specialRegexpChars.test(value)) {\n throw new Error(\n `Invalid debug value: \"${value}\" (contains special chars)`,\n );\n }\n\n if (!value) return;\n\n if (value === '*') {\n isWildcard = true;\n return;\n }\n\n if (value.startsWith('-')) {\n skips.push(createTestFunctionFromValue(value.slice(1)));\n } else if (!isWildcard) {\n debugValues.push(createTestFunctionFromValue(value));\n }\n });\n }\n\n if (isWildcard) {\n if (skips.length === 0) {\n return () => Level.ALL;\n } else {\n return (minLevel: Level, key: string) =>\n skips.some((skip) => skip(key)) ? minLevel : Level.ALL;\n }\n }\n\n if (debugValues.length === 0) {\n return (minLevel: Level) => minLevel;\n }\n\n return (minLevel: Level, key: string) => {\n if (minLevel === Level.ALL || !key) {\n return minLevel;\n }\n\n if (debugValues.some((dv) => dv(key))) {\n return skips.some((skip) => skip(key)) ? minLevel : Level.ALL;\n }\n\n return minLevel;\n };\n}\n"],"names":["specialRegexpChars","createTestFunctionFromRegexp","regexp","string","test","createTestFunctionFromRegexpString","value","endsWith","Error","RegExp","slice","createTestFunctionFromValue","startsWith","createFindDebugLevel","debugValue","isWildcard","debugValues","skips","Array","isArray","push","undefined","trim","split","forEach","length","Level","ALL","minLevel","key","some","skip","dv"],"mappings":";;AAAA;AAGA,MAAMA,kBAAkB,GAAG,mBAAmB,CAAA;AAK9C,MAAMC,4BAA4B,GAC/BC,MAAc,IACdC,MAAc,IACbD,MAAM,CAACE,IAAI,CAACD,MAAM,CAAC,CAAA;AAEvB,MAAME,kCAAkC,GAAIC,KAAa,IAAmB;AAC1E,EAAA,IAAI,CAACA,KAAK,CAACC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,IAAIC,KAAK,CAAC,4BAA4B,CAAC,CAAA;AACvE,EAAA,OAAOP,4BAA4B,CAAC,IAAIQ,MAAM,CAACH,KAAK,CAACI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACrE,CAAC,CAAA;AAED,MAAMC,2BAA2B,GAAIL,KAAa,IAAmB;AACnE,EAAA,IAAIA,KAAK,CAACC,QAAQ,CAAC,IAAI,CAAC,EAAE;IACxBD,KAAK,GAAGA,KAAK,CAACI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAC1B,IAAA,OAAQP,MAAc,IAAKA,MAAM,CAACS,UAAU,CAACN,KAAK,CAAC,CAAA;AACrD,GAAA;AAEA,EAAA,OAAQH,MAAc,IAAKA,MAAM,KAAKG,KAAK,CAAA;AAC7C,CAAC,CAAA;AAIM,SAASO,oBAAoBA,CAClCC,UAA2B,EACX;EAChB,I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
|
-
"parserOptions": {
|
|
5
|
-
"project": "packages/nightingale-debug/tsconfig.json"
|
|
6
|
-
},
|
|
7
|
-
"plugins": ["@typescript-eslint"],
|
|
8
|
-
"extends": ["@pob/eslint-config-typescript"],
|
|
9
|
-
"ignorePatterns": ["*.d.ts"],
|
|
10
|
-
"overrides": [
|
|
11
|
-
{
|
|
12
|
-
"files": ["**/*.test.ts", "__tests__/**/*.ts"],
|
|
13
|
-
"extends": ["@pob/eslint-config-typescript/test"],
|
|
14
|
-
"env": {
|
|
15
|
-
"jest": true
|
|
16
|
-
},
|
|
17
|
-
"rules": {
|
|
18
|
-
"import/no-extraneous-dependencies": [
|
|
19
|
-
"error",
|
|
20
|
-
{
|
|
21
|
-
"devDependencies": true
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|
package/src/index.test.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Level } from 'nightingale-levels';
|
|
2
|
-
import { createFindDebugLevel } from '.';
|
|
3
|
-
|
|
4
|
-
describe('created with undefined', () => {
|
|
5
|
-
const findDebugLevel = createFindDebugLevel();
|
|
6
|
-
test('should always return level passed', () => {
|
|
7
|
-
expect(findDebugLevel(Level.ALL, 'app')).toBe(Level.ALL);
|
|
8
|
-
expect(findDebugLevel(Level.TRACE, 'app')).toBe(Level.TRACE);
|
|
9
|
-
expect(findDebugLevel(Level.INFO, 'app')).toBe(Level.INFO);
|
|
10
|
-
expect(findDebugLevel(Level.WARN, 'app')).toBe(Level.WARN);
|
|
11
|
-
expect(findDebugLevel(Level.FATAL, 'app')).toBe(Level.FATAL);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
describe('created with *', () => {
|
|
16
|
-
const findDebugLevel = createFindDebugLevel('*');
|
|
17
|
-
test('should always return level ALL', () => {
|
|
18
|
-
expect(findDebugLevel(Level.ALL, 'app')).toBe(Level.ALL);
|
|
19
|
-
expect(findDebugLevel(Level.TRACE, 'app')).toBe(Level.ALL);
|
|
20
|
-
expect(findDebugLevel(Level.INFO, 'app')).toBe(Level.ALL);
|
|
21
|
-
expect(findDebugLevel(Level.WARN, 'app')).toBe(Level.ALL);
|
|
22
|
-
expect(findDebugLevel(Level.FATAL, 'app')).toBe(Level.ALL);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe('created with *,-app:*', () => {
|
|
27
|
-
const findDebugLevel = createFindDebugLevel('*,-app:*');
|
|
28
|
-
test('app: should always return level passed', () => {
|
|
29
|
-
expect(findDebugLevel(Level.ALL, 'app')).toBe(Level.ALL);
|
|
30
|
-
expect(findDebugLevel(Level.INFO, 'app')).toBe(Level.INFO);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('not app: should always return level ALL', () => {
|
|
34
|
-
expect(findDebugLevel(Level.ALL, 'nightingale')).toBe(Level.ALL);
|
|
35
|
-
expect(findDebugLevel(Level.INFO, 'nightingale')).toBe(Level.ALL);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('created with nightingale,-nightingale:debug', () => {
|
|
40
|
-
const findDebugLevel = createFindDebugLevel('nightingale,-nightingale:debug');
|
|
41
|
-
test('nightingale:debug: should always return level passed', () => {
|
|
42
|
-
expect(findDebugLevel(Level.ALL, 'nightingale:debug')).toBe(Level.ALL);
|
|
43
|
-
expect(findDebugLevel(Level.INFO, 'nightingale:debug')).toBe(Level.INFO);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('nightingale: should always return level ALL', () => {
|
|
47
|
-
expect(findDebugLevel(Level.ALL, 'nightingale')).toBe(Level.ALL);
|
|
48
|
-
expect(findDebugLevel(Level.INFO, 'nightingale')).toBe(Level.ALL);
|
|
49
|
-
});
|
|
50
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/* eslint-disable complexity */
|
|
2
|
-
import { Level } from 'nightingale-levels';
|
|
3
|
-
|
|
4
|
-
const specialRegexpChars = /[$()+.?[\\\]^{|}]/;
|
|
5
|
-
|
|
6
|
-
type TestFunction = (string: string) => boolean;
|
|
7
|
-
export type DebugValueType = RegExp | string[] | string;
|
|
8
|
-
|
|
9
|
-
const createTestFunctionFromRegexp =
|
|
10
|
-
(regexp: RegExp): TestFunction =>
|
|
11
|
-
(string: string) =>
|
|
12
|
-
regexp.test(string);
|
|
13
|
-
|
|
14
|
-
const createTestFunctionFromRegexpString = (value: string): TestFunction => {
|
|
15
|
-
if (!value.endsWith('/')) throw new Error('Invalid RegExp DEBUG value');
|
|
16
|
-
return createTestFunctionFromRegexp(new RegExp(value.slice(1, -1)));
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const createTestFunctionFromValue = (value: string): TestFunction => {
|
|
20
|
-
if (value.endsWith(':*')) {
|
|
21
|
-
value = value.slice(0, -2);
|
|
22
|
-
return (string: string) => string.startsWith(value);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return (string: string) => string === value;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type FindDebugLevel = (minLevel: Level, key: string) => Level;
|
|
29
|
-
|
|
30
|
-
export function createFindDebugLevel(
|
|
31
|
-
debugValue?: DebugValueType,
|
|
32
|
-
): FindDebugLevel {
|
|
33
|
-
let isWildcard = false;
|
|
34
|
-
const debugValues: TestFunction[] = [];
|
|
35
|
-
const skips: TestFunction[] = [];
|
|
36
|
-
|
|
37
|
-
if (!Array.isArray(debugValue)) {
|
|
38
|
-
if (debugValue instanceof RegExp) {
|
|
39
|
-
debugValues.push(createTestFunctionFromRegexp(debugValue));
|
|
40
|
-
debugValue = undefined;
|
|
41
|
-
} else if (debugValue) {
|
|
42
|
-
debugValue = debugValue.trim();
|
|
43
|
-
|
|
44
|
-
if (debugValue.startsWith('/')) {
|
|
45
|
-
debugValues.push(createTestFunctionFromRegexpString(debugValue));
|
|
46
|
-
debugValue = undefined;
|
|
47
|
-
} else {
|
|
48
|
-
debugValue = debugValue.split(/[\s,]+/);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (debugValue) {
|
|
54
|
-
(debugValue as string[]).forEach((value) => {
|
|
55
|
-
if (specialRegexpChars.test(value)) {
|
|
56
|
-
throw new Error(
|
|
57
|
-
`Invalid debug value: "${value}" (contains special chars)`,
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (!value) return;
|
|
62
|
-
|
|
63
|
-
if (value === '*') {
|
|
64
|
-
isWildcard = true;
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (value.startsWith('-')) {
|
|
69
|
-
skips.push(createTestFunctionFromValue(value.slice(1)));
|
|
70
|
-
} else if (!isWildcard) {
|
|
71
|
-
debugValues.push(createTestFunctionFromValue(value));
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (isWildcard) {
|
|
77
|
-
if (skips.length === 0) {
|
|
78
|
-
return () => Level.ALL;
|
|
79
|
-
} else {
|
|
80
|
-
return (minLevel: Level, key: string) =>
|
|
81
|
-
skips.some((skip) => skip(key)) ? minLevel : Level.ALL;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (debugValues.length === 0) {
|
|
86
|
-
return (minLevel: Level) => minLevel;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return (minLevel: Level, key: string) => {
|
|
90
|
-
if (minLevel === Level.ALL || !key) {
|
|
91
|
-
return minLevel;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (debugValues.some((dv) => dv(key))) {
|
|
95
|
-
return skips.some((skip) => skip(key)) ? minLevel : Level.ALL;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return minLevel;
|
|
99
|
-
};
|
|
100
|
-
}
|