@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.
@@ -7,3 +7,7 @@ export declare const buildObject: <T>(...props: {
7
7
  value: any;
8
8
  }[]) => T;
9
9
  export declare const mergeDeep: <T>(a: any, b: any) => T;
10
+ export declare const jsonSerialize: (obj: any, options?: {
11
+ stripBinaryData?: boolean;
12
+ prettify?: boolean;
13
+ }) => string;
package/dist/esm/index.js CHANGED
@@ -424,6 +424,24 @@ const mergeDeep = (a, b) => {
424
424
  }
425
425
  return c;
426
426
  };
427
+ const jsonSerialize = (obj, options) => {
428
+ const { stripBinaryData = true, prettify = false } = options ?? {};
429
+ const replacer = (key, value) => {
430
+ if (stripBinaryData) {
431
+ if (value instanceof Buffer) {
432
+ return `<binary data (${value.length} bytes)>`;
433
+ }
434
+ if (typeof value === "object" &&
435
+ value.type === "Buffer" &&
436
+ Array.isArray(value.data)) {
437
+ return `<binary data (${value.data.length} bytes)>`;
438
+ }
439
+ }
440
+ return value;
441
+ };
442
+ const spaces = prettify ? 2 : undefined;
443
+ return JSON.stringify(obj, replacer, spaces);
444
+ };
427
445
 
428
446
  const pluralize = (word) => {
429
447
  return word.endsWith("s") ? `${word}es` : `${word}s`;
@@ -28527,5 +28545,5 @@ const processArrayItemMove = (items, input) => {
28527
28545
  }));
28528
28546
  };
28529
28547
 
28530
- export { ExcelKeyTransform, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, csvBuild, csvParse, distinct, distinctElements, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, getDirectoryFilePaths, getDirectoryPath, groupBy, indexes, isNullOrUndefined, iterate, joinPath, jsonDistinct, last, logMemoryUsage, mapOrThrow, mergeDeep, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, selectMany, sleep, sort, splitPath, subArrays, subtractTime, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart };
28548
+ export { ExcelKeyTransform, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, csvBuild, csvParse, distinct, distinctElements, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, getDirectoryFilePaths, getDirectoryPath, groupBy, indexes, isNullOrUndefined, iterate, joinPath, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapOrThrow, mergeDeep, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, selectMany, sleep, sort, splitPath, subArrays, subtractTime, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart };
28531
28549
  //# sourceMappingURL=index.js.map