@punks/backend-core 0.0.27 → 0.0.28
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.
|
@@ -2,3 +2,7 @@ export declare const removeUndefinedProps: <T extends Record<string, any>>(obj:
|
|
|
2
2
|
recursive?: boolean;
|
|
3
3
|
}) => T;
|
|
4
4
|
export declare const isNullOrUndefined: (value: any) => boolean;
|
|
5
|
+
export declare const buildObject: <T>(...props: {
|
|
6
|
+
key: string;
|
|
7
|
+
value: any;
|
|
8
|
+
}[]) => T;
|
package/dist/esm/index.js
CHANGED
|
@@ -314,6 +314,27 @@ const removeUndefinedProps = (obj, options = { recursive: false }) => {
|
|
|
314
314
|
const isNullOrUndefined = (value) => {
|
|
315
315
|
return value === null || value === undefined;
|
|
316
316
|
};
|
|
317
|
+
const buildObject = (...props) => {
|
|
318
|
+
const out = {};
|
|
319
|
+
for (const prop of props) {
|
|
320
|
+
const propPath = prop.key.split(".");
|
|
321
|
+
const propName = propPath[0];
|
|
322
|
+
const nestedPropPath = propPath.slice(1).join(".");
|
|
323
|
+
if (nestedPropPath) {
|
|
324
|
+
out[propName] = {
|
|
325
|
+
...(out[propName] ?? {}),
|
|
326
|
+
...buildObject({
|
|
327
|
+
key: nestedPropPath,
|
|
328
|
+
value: prop.value,
|
|
329
|
+
}),
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
out[propName] = prop.value;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return out;
|
|
337
|
+
};
|
|
317
338
|
|
|
318
339
|
const pluralize = (word) => {
|
|
319
340
|
return word.endsWith("s") ? `${word}es` : `${word}s`;
|
|
@@ -28354,5 +28375,5 @@ const excelParse = (file, options) => {
|
|
|
28354
28375
|
.map((x) => aggregateRow(header, x, options));
|
|
28355
28376
|
};
|
|
28356
28377
|
|
|
28357
|
-
export { ExcelKeyTransform, Log, LogLevel, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, csvBuild, csvParse, distinct, distinctElements, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, getDirectoryFilePaths, getDirectoryPath, indexes, isNullOrUndefined, iterate, joinPath, jsonDistinct, last, mapOrThrow, newUuid, notNull, notUndefined, pluralize, range, removeUndefinedProps, selectMany, sleep, sort, splitPath, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart };
|
|
28378
|
+
export { ExcelKeyTransform, Log, LogLevel, buildObject, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, csvBuild, csvParse, distinct, distinctElements, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, getDirectoryFilePaths, getDirectoryPath, indexes, isNullOrUndefined, iterate, joinPath, jsonDistinct, last, mapOrThrow, newUuid, notNull, notUndefined, pluralize, range, removeUndefinedProps, selectMany, sleep, sort, splitPath, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart };
|
|
28358
28379
|
//# sourceMappingURL=index.js.map
|