@punks/backend-core 0.0.43 → 0.0.44
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 +19 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/objects/index.d.ts +4 -0
- package/dist/cjs/types/utils/objects/jsonSerialize.spec.d.ts +1 -0
- package/dist/esm/index.js +19 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/objects/index.d.ts +4 -0
- package/dist/esm/types/utils/objects/jsonSerialize.spec.d.ts +1 -0
- package/dist/index.d.ts +5 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -433,6 +433,24 @@ const mergeDeep = (a, b) => {
|
|
|
433
433
|
}
|
|
434
434
|
return c;
|
|
435
435
|
};
|
|
436
|
+
const jsonSerialize = (obj, options) => {
|
|
437
|
+
const { stripBinaryData = true, prettify = false } = options ?? {};
|
|
438
|
+
const replacer = (key, value) => {
|
|
439
|
+
if (stripBinaryData) {
|
|
440
|
+
if (value instanceof Buffer) {
|
|
441
|
+
return `<binary data (${value.length} bytes)>`;
|
|
442
|
+
}
|
|
443
|
+
if (typeof value === "object" &&
|
|
444
|
+
value.type === "Buffer" &&
|
|
445
|
+
Array.isArray(value.data)) {
|
|
446
|
+
return `<binary data (${value.data.length} bytes)>`;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return value;
|
|
450
|
+
};
|
|
451
|
+
const spaces = prettify ? 2 : undefined;
|
|
452
|
+
return JSON.stringify(obj, replacer, spaces);
|
|
453
|
+
};
|
|
436
454
|
|
|
437
455
|
const pluralize = (word) => {
|
|
438
456
|
return word.endsWith("s") ? `${word}es` : `${word}s`;
|
|
@@ -28563,6 +28581,7 @@ exports.isNullOrUndefined = isNullOrUndefined;
|
|
|
28563
28581
|
exports.iterate = iterate;
|
|
28564
28582
|
exports.joinPath = joinPath;
|
|
28565
28583
|
exports.jsonDistinct = jsonDistinct;
|
|
28584
|
+
exports.jsonSerialize = jsonSerialize;
|
|
28566
28585
|
exports.last = last;
|
|
28567
28586
|
exports.logMemoryUsage = logMemoryUsage;
|
|
28568
28587
|
exports.mapOrThrow = mapOrThrow;
|