@punks/backend-core 0.0.26 → 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.
- package/dist/cjs/index.js +25 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/mappings.d.ts +4 -4
- package/dist/cjs/types/utils/objects.d.ts +4 -0
- package/dist/esm/index.js +25 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/mappings.d.ts +4 -4
- package/dist/esm/types/utils/objects.d.ts +4 -0
- package/dist/index.d.ts +9 -5
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -323,6 +323,27 @@ const removeUndefinedProps = (obj, options = { recursive: false }) => {
|
|
|
323
323
|
const isNullOrUndefined = (value) => {
|
|
324
324
|
return value === null || value === undefined;
|
|
325
325
|
};
|
|
326
|
+
const buildObject = (...props) => {
|
|
327
|
+
const out = {};
|
|
328
|
+
for (const prop of props) {
|
|
329
|
+
const propPath = prop.key.split(".");
|
|
330
|
+
const propName = propPath[0];
|
|
331
|
+
const nestedPropPath = propPath.slice(1).join(".");
|
|
332
|
+
if (nestedPropPath) {
|
|
333
|
+
out[propName] = {
|
|
334
|
+
...(out[propName] ?? {}),
|
|
335
|
+
...buildObject({
|
|
336
|
+
key: nestedPropPath,
|
|
337
|
+
value: prop.value,
|
|
338
|
+
}),
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
out[propName] = prop.value;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return out;
|
|
346
|
+
};
|
|
326
347
|
|
|
327
348
|
const pluralize = (word) => {
|
|
328
349
|
return word.endsWith("s") ? `${word}es` : `${word}s`;
|
|
@@ -332,10 +353,10 @@ function sleep(ms) {
|
|
|
332
353
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
333
354
|
}
|
|
334
355
|
|
|
335
|
-
const mapOrThrow = (
|
|
336
|
-
const output = mapper(
|
|
356
|
+
const mapOrThrow = ({ mapper, throw: throwFn, }) => {
|
|
357
|
+
const output = mapper();
|
|
337
358
|
if (!output) {
|
|
338
|
-
return throwFn(
|
|
359
|
+
return throwFn();
|
|
339
360
|
}
|
|
340
361
|
return output;
|
|
341
362
|
};
|
|
@@ -28364,6 +28385,7 @@ const excelParse = (file, options) => {
|
|
|
28364
28385
|
};
|
|
28365
28386
|
|
|
28366
28387
|
exports.Log = Log;
|
|
28388
|
+
exports.buildObject = buildObject;
|
|
28367
28389
|
exports.byField = byField;
|
|
28368
28390
|
exports.byFieldDesc = byFieldDesc;
|
|
28369
28391
|
exports.camelToKebabCase = camelToKebabCase;
|