@typeberry/lib 0.5.8-0dea783 → 0.5.8-dbdc34c
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/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../../../packages/core/utils/debug.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,YAExB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,cAA6F,CAAC;AAE9G;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CACnB,OAAO,EAAE,oBAAoB,EAC7B,SAAS,EAAE,OAAO,EAClB,GAAG,IAAI,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC,SAAS,IAAI,IAAI,CAO3B;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAE/C;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,QAKpE;AAED,6BAA6B;AAC7B,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../../../packages/core/utils/debug.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,YAExB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,cAA6F,CAAC;AAE9G;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CACnB,OAAO,EAAE,oBAAoB,EAC7B,SAAS,EAAE,OAAO,EAClB,GAAG,IAAI,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC,SAAS,IAAI,IAAI,CAO3B;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAE/C;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,QAKpE;AAED,6BAA6B;AAC7B,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAEzC;AAkED,sEAAsE;AACtE,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,gBAGjC;AAED,mFAAmF;AACnF,8BAAsB,SAAS;IAC7B,QAAQ;CAGT;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;;EAMpC"}
|
|
@@ -55,6 +55,12 @@ export function assertEmpty(value) {
|
|
|
55
55
|
}
|
|
56
56
|
/** Debug print an object. */
|
|
57
57
|
export function inspect(val) {
|
|
58
|
+
return inspectInternal(val, new WeakSet());
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Internal implementation of inspect with circular reference detection.
|
|
62
|
+
*/
|
|
63
|
+
function inspectInternal(val, seen) {
|
|
58
64
|
const nest = (v) => v
|
|
59
65
|
.split("\n")
|
|
60
66
|
.map((x) => ` ${x}`)
|
|
@@ -67,10 +73,10 @@ export function inspect(val) {
|
|
|
67
73
|
return "<undefined>";
|
|
68
74
|
}
|
|
69
75
|
if (Array.isArray(val)) {
|
|
70
|
-
return `[${val.map((x) =>
|
|
76
|
+
return `[${val.map((x) => inspectInternal(x, seen))}]`;
|
|
71
77
|
}
|
|
72
78
|
if (val instanceof Map) {
|
|
73
|
-
return
|
|
79
|
+
return inspectInternal(Array.from(val.entries()), seen);
|
|
74
80
|
}
|
|
75
81
|
if (typeof val === "number") {
|
|
76
82
|
return `${val} (0x${val.toString(16)})`;
|
|
@@ -78,6 +84,11 @@ export function inspect(val) {
|
|
|
78
84
|
if (typeof val !== "object") {
|
|
79
85
|
return `${val}`;
|
|
80
86
|
}
|
|
87
|
+
// Check for circular references
|
|
88
|
+
if (seen.has(val)) {
|
|
89
|
+
return "<circular>";
|
|
90
|
+
}
|
|
91
|
+
seen.add(val);
|
|
81
92
|
if ("toString" in val &&
|
|
82
93
|
Object.prototype.toString !== val.toString &&
|
|
83
94
|
WithDebug.prototype.toString !== val.toString) {
|
|
@@ -90,7 +101,7 @@ export function inspect(val) {
|
|
|
90
101
|
for (const k of keys) {
|
|
91
102
|
if (typeof k === "string") {
|
|
92
103
|
v += oneLine ? "" : "\n ";
|
|
93
|
-
v += `${k}: ${nest(
|
|
104
|
+
v += `${k}: ${nest(inspectInternal(val[k], seen))}`;
|
|
94
105
|
v += oneLine ? "," : "";
|
|
95
106
|
}
|
|
96
107
|
}
|