@darksheep/logger 1.0.3 → 1.0.5
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 +23 -0
- package/package.json +3 -8
- package/src/replacer.js +47 -38
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.5](https://github.com/DarkSheepSoftware/node-packages/compare/logger-v1.0.4...logger-v1.0.5) (2024-09-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Dependencies
|
|
7
|
+
|
|
8
|
+
* The following workspace dependencies were updated
|
|
9
|
+
* dependencies
|
|
10
|
+
* @darksheep/environment bumped from 3.0.7 to 3.0.8
|
|
11
|
+
|
|
12
|
+
## [1.0.4](https://github.com/DarkSheepSoftware/node-packages/compare/logger-v1.0.3...logger-v1.0.4) (2024-08-28)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### 🔨 Code Refactoring
|
|
16
|
+
|
|
17
|
+
* Remove all eslint inline suppressions ([dc1d62f](https://github.com/DarkSheepSoftware/node-packages/commit/dc1d62f5fa9cd50f884d6b68a30d448685c6c2d2))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Dependencies
|
|
21
|
+
|
|
22
|
+
* The following workspace dependencies were updated
|
|
23
|
+
* dependencies
|
|
24
|
+
* @darksheep/environment bumped from 3.0.6 to 3.0.7
|
|
25
|
+
|
|
3
26
|
## [1.0.3](https://github.com/DarkSheepSoftware/node-packages/compare/logger-v1.0.2...logger-v1.0.3) (2024-08-12)
|
|
4
27
|
|
|
5
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darksheep/logger",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Logging your stuff to where ever you want it",
|
|
5
5
|
"license": "UNLICENCED",
|
|
6
6
|
"type": "module",
|
|
@@ -17,24 +17,19 @@
|
|
|
17
17
|
"!assert.zod.js"
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
|
-
"lint": "eslint .",
|
|
21
|
-
"lint:fix": "eslint . --fix",
|
|
22
20
|
"prepack": "tsc",
|
|
23
21
|
"test": "node --test src/**/*.test.js",
|
|
24
22
|
"test:watch": "node --watch --test src/**/*.test.js"
|
|
25
23
|
},
|
|
26
24
|
"dependencies": {
|
|
27
|
-
"@darksheep/environment": "3.0.
|
|
25
|
+
"@darksheep/environment": "3.0.8",
|
|
28
26
|
"deepmerge-ts": "7.1.0",
|
|
29
27
|
"stacktrace-parser": "0.1.10",
|
|
30
28
|
"traverse": "0.6.9"
|
|
31
29
|
},
|
|
32
30
|
"devDependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@types/eslint": "~9.6.0",
|
|
35
|
-
"@types/node": "~20.14.0",
|
|
31
|
+
"@types/node": "~20.16.0",
|
|
36
32
|
"@types/traverse": "~0.6.33",
|
|
37
|
-
"eslint": "~9.9.0",
|
|
38
33
|
"nock": "~13.5.0",
|
|
39
34
|
"typescript": "~5.5.0",
|
|
40
35
|
"zod": "~3.23.0"
|
package/src/replacer.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint no-invalid-this: 0 */
|
|
2
|
-
|
|
3
1
|
import Traverse from 'traverse';
|
|
4
2
|
|
|
5
3
|
import { nodesToPath } from './utilities/json-path.js';
|
|
@@ -20,50 +18,61 @@ import { nodesToPath } from './utilities/json-path.js';
|
|
|
20
18
|
* @returns {unknown}
|
|
21
19
|
*/
|
|
22
20
|
export function replace(object, replacers = []) {
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
return Traverse(object).forEach(
|
|
22
|
+
/**
|
|
23
|
+
* @param {unknown} value Current property in the traversed object
|
|
24
|
+
* @this {import('traverse').TraverseContext}
|
|
25
|
+
* @returns {void}
|
|
26
|
+
*/
|
|
27
|
+
function (value) {
|
|
28
|
+
if (value == null) {
|
|
29
|
+
return this.remove();
|
|
30
|
+
}
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
32
|
+
if (this.circular != null) {
|
|
33
|
+
return this.update({ $ref: nodesToPath(this.circular.path) });
|
|
34
|
+
}
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
for (const replacer of replacers) {
|
|
37
|
+
if (replacer.shouldReplace(value, this.path)) {
|
|
38
|
+
const replaced = replacer.replace(value, this.path);
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
if (replaced == null) {
|
|
41
|
+
return this.remove(replacer.stopHere);
|
|
42
|
+
}
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
return this.remove(replacer.stopHere);
|
|
44
|
+
return this.update(replaced, replacer.stopHere);
|
|
41
45
|
}
|
|
42
|
-
|
|
43
|
-
return this.update(replaced, replacer.stopHere);
|
|
44
46
|
}
|
|
45
|
-
}
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
if (
|
|
49
|
+
typeof value === 'object' &&
|
|
50
|
+
'toJSON' in value &&
|
|
51
|
+
typeof value.toJSON === 'function'
|
|
52
|
+
) {
|
|
53
|
+
try {
|
|
54
|
+
return this.update(value.toJSON());
|
|
55
|
+
} catch { }
|
|
56
|
+
}
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
if (
|
|
59
|
+
value instanceof Object &&
|
|
60
|
+
Object.getPrototypeOf(value) !== Object.getPrototypeOf({}) &&
|
|
61
|
+
Object.getPrototypeOf(value) !== Object.getPrototypeOf([])
|
|
62
|
+
) {
|
|
63
|
+
return this.update({ $class: value.constructor.name });
|
|
64
|
+
}
|
|
60
65
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
if (Object.getPrototypeOf(value).constructor === Object) {
|
|
67
|
+
this.update({ ...value });
|
|
68
|
+
}
|
|
64
69
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
if (
|
|
71
|
+
Array.isArray(value) &&
|
|
72
|
+
Object.getPrototypeOf(value).constructor === Array
|
|
73
|
+
) {
|
|
74
|
+
this.update([ ...value ]);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
);
|
|
69
78
|
}
|