@punks/backend-core 0.0.47 → 0.0.48
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/dist/cjs/index.js +14 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/objects/index.d.ts +1 -0
- package/dist/esm/index.js +14 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/objects/index.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -297,13 +297,25 @@ const mergeDeep = (a, b) => {
|
|
|
297
297
|
return c;
|
|
298
298
|
};
|
|
299
299
|
const jsonSerialize = (obj, options) => {
|
|
300
|
-
const { stripBinaryData = true, prettify = false, maxStringsLength, } = options ?? {};
|
|
300
|
+
const { removeCircularReferences = true, stripBinaryData = true, prettify = false, maxStringsLength, } = options ?? {};
|
|
301
301
|
const replacer = (key, value) => {
|
|
302
|
-
|
|
302
|
+
// remove circular references
|
|
303
|
+
const seen = new WeakSet();
|
|
304
|
+
if (removeCircularReferences &&
|
|
305
|
+
typeof value === "object" &&
|
|
306
|
+
value !== null) {
|
|
307
|
+
if (seen.has(value)) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
seen.add(value);
|
|
311
|
+
}
|
|
312
|
+
// trim long strings
|
|
313
|
+
if (maxStringsLength && typeof value === "string") {
|
|
303
314
|
return value.length > maxStringsLength
|
|
304
315
|
? `${value.substring(0, maxStringsLength)}...`
|
|
305
316
|
: value;
|
|
306
317
|
}
|
|
318
|
+
// strip binary data
|
|
307
319
|
if (stripBinaryData) {
|
|
308
320
|
if (value instanceof Buffer) {
|
|
309
321
|
return `<binary data (${value.length} bytes)>`;
|