@punks/backend-core 0.0.48 → 0.0.49
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 +21 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/objects/index.d.ts +1 -0
- package/dist/esm/index.js +21 -6
- 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
|
@@ -296,9 +296,22 @@ const mergeDeep = (a, b) => {
|
|
|
296
296
|
}
|
|
297
297
|
return c;
|
|
298
298
|
};
|
|
299
|
+
const isSerializable = (obj) => {
|
|
300
|
+
try {
|
|
301
|
+
JSON.stringify(obj);
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
catch (e) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
};
|
|
299
308
|
const jsonSerialize = (obj, options) => {
|
|
300
|
-
const { removeCircularReferences = true, stripBinaryData = true, prettify = false, maxStringsLength, } = options ?? {};
|
|
309
|
+
const { removeNonSerializableObjects = true, removeCircularReferences = true, stripBinaryData = true, prettify = false, maxStringsLength, } = options ?? {};
|
|
301
310
|
const replacer = (key, value) => {
|
|
311
|
+
// remove non serializable objects
|
|
312
|
+
if (removeNonSerializableObjects && !isSerializable(value)) {
|
|
313
|
+
return `<non serializable property ${typeof value}>`;
|
|
314
|
+
}
|
|
302
315
|
// remove circular references
|
|
303
316
|
const seen = new WeakSet();
|
|
304
317
|
if (removeCircularReferences &&
|
|
@@ -28492,16 +28505,18 @@ class InternalLogger {
|
|
|
28492
28505
|
}
|
|
28493
28506
|
}
|
|
28494
28507
|
serializeMeta(meta) {
|
|
28495
|
-
const serializedMeta =
|
|
28496
|
-
|
|
28497
|
-
|
|
28498
|
-
|
|
28508
|
+
const serializedMeta = meta
|
|
28509
|
+
? jsonSerialize(meta, {
|
|
28510
|
+
prettify: true,
|
|
28511
|
+
stripBinaryData: true,
|
|
28512
|
+
})
|
|
28513
|
+
: undefined;
|
|
28499
28514
|
switch (this.options.serialization) {
|
|
28500
28515
|
case exports.MetaSerializationType.JSON:
|
|
28501
28516
|
return serializedMeta;
|
|
28502
28517
|
case exports.MetaSerializationType.None:
|
|
28503
28518
|
default:
|
|
28504
|
-
return JSON.parse(serializedMeta);
|
|
28519
|
+
return serializedMeta ? JSON.parse(serializedMeta) : undefined;
|
|
28505
28520
|
}
|
|
28506
28521
|
}
|
|
28507
28522
|
}
|