@punks/backend-core 0.0.79 → 0.0.80

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.
@@ -5,7 +5,7 @@ export { CsvColumnDefinition, CsvBuildOptions, csvBuild, csvParse } from "./csv"
5
5
  export { getDirectoryFilePaths } from "./files";
6
6
  export { joinPath, splitPath, ensureDirectory, getDirectoryPath, createDayPath, } from "./paths";
7
7
  export * from "./strings";
8
- export * from "./objects";
8
+ export { buildObject, isNullOrUndefined, jsonSerialize, mergeDeep, removeUndefinedProps, replaceUndefinedWithNull, } from "./objects";
9
9
  export * from "./encoding";
10
10
  export { stripTags } from "./html";
11
11
  export { maskVariable } from "./variables";
@@ -1,3 +1,4 @@
1
+ import { ReplaceUndefinedWithNull } from "./types";
1
2
  export declare const removeUndefinedProps: <T extends Record<string, any>>(obj: T, options?: {
2
3
  recursive?: boolean;
3
4
  }) => T;
@@ -14,3 +15,4 @@ export declare const jsonSerialize: (obj: any, options?: {
14
15
  maxStringsLength?: number;
15
16
  prettify?: boolean;
16
17
  }) => string;
18
+ export declare function replaceUndefinedWithNull<T>(obj: T): ReplaceUndefinedWithNull<T>;
@@ -0,0 +1,3 @@
1
+ export type ReplaceUndefinedWithNull<T> = T extends undefined ? null : T extends (infer U)[] ? ReplaceUndefinedWithNull<U>[] : T extends object ? {
2
+ [K in keyof T]: ReplaceUndefinedWithNull<T[K]>;
3
+ } : T;
package/dist/esm/index.js CHANGED
@@ -411,6 +411,24 @@ const jsonSerialize = (obj, options) => {
411
411
  const spaces = prettify ? 2 : undefined;
412
412
  return JSON.stringify(obj, replacer, spaces);
413
413
  };
414
+ function replaceUndefinedWithNull(obj) {
415
+ if (obj === undefined) {
416
+ return null;
417
+ }
418
+ if (typeof obj !== "object" || obj === null) {
419
+ return obj;
420
+ }
421
+ if (Array.isArray(obj)) {
422
+ return obj.map(replaceUndefinedWithNull);
423
+ }
424
+ const newObj = {};
425
+ for (const key in obj) {
426
+ if (obj.hasOwnProperty(key)) {
427
+ newObj[key] = replaceUndefinedWithNull(obj[key]);
428
+ }
429
+ }
430
+ return newObj;
431
+ }
414
432
 
415
433
  const encodeUtf8 = (value) => Buffer.from(value).toString("utf-8");
416
434
  const decodeUtf8 = (value) => Buffer.from(value, "utf-8");
@@ -31448,5 +31466,5 @@ const processArrayItemMove = (items, input) => {
31448
31466
  }));
31449
31467
  };
31450
31468
 
31451
- export { ConsoleLogger, DatadogLogger, ExcelKeyTransform, FileLogger, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, buildUrl, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, createDayPath, csvBuild, csvParse, decodeBase64, decodeUtf8, deserializeQueryString, distinct, distinctElements, encodeBase64, encodeUtf8, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, floorDateToSecond, generateHash, getDirectoryFilePaths, getDirectoryPath, getQueryParameter, groupBy, indexes, isNullOrUndefined, iterate, joinPath, joinUrl, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapAsync, mapOrThrow, maskVariable, mergeDeep, multipleSplit, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, selectMany, serializeQueryString, sleep, sort, splitPath, stripTags, subArrays, subtractTime, testInternetConnection, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart, updateQueryParameters };
31469
+ export { ConsoleLogger, DatadogLogger, ExcelKeyTransform, FileLogger, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, buildUrl, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, createDayPath, csvBuild, csvParse, decodeBase64, decodeUtf8, deserializeQueryString, distinct, distinctElements, encodeBase64, encodeUtf8, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, floorDateToSecond, generateHash, getDirectoryFilePaths, getDirectoryPath, getQueryParameter, groupBy, indexes, isNullOrUndefined, iterate, joinPath, joinUrl, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapAsync, mapOrThrow, maskVariable, mergeDeep, multipleSplit, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, replaceUndefinedWithNull, selectMany, serializeQueryString, sleep, sort, splitPath, stripTags, subArrays, subtractTime, testInternetConnection, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart, updateQueryParameters };
31452
31470
  //# sourceMappingURL=index.js.map