@punks/backend-core 0.0.42 → 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 +33 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/functions/index.d.ts +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 +32 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/functions/index.d.ts +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 +14 -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`;
|
|
@@ -28522,6 +28540,19 @@ const processArrayDifferences = ({ elements, elementIdSelector, desiredItems, de
|
|
|
28522
28540
|
correspondingElements,
|
|
28523
28541
|
};
|
|
28524
28542
|
};
|
|
28543
|
+
const processArrayItemMove = (items, input) => {
|
|
28544
|
+
const { oldIndex, newIndex } = input;
|
|
28545
|
+
const item = items[oldIndex];
|
|
28546
|
+
const newItems = [...items];
|
|
28547
|
+
newItems.splice(oldIndex, 1);
|
|
28548
|
+
newItems.splice(newIndex, 0, item);
|
|
28549
|
+
return newItems.map((x, i) => ({
|
|
28550
|
+
item: x,
|
|
28551
|
+
newIndex: i,
|
|
28552
|
+
oldIndex: items.indexOf(x),
|
|
28553
|
+
isMoved: i !== items.indexOf(x),
|
|
28554
|
+
}));
|
|
28555
|
+
};
|
|
28525
28556
|
|
|
28526
28557
|
exports.Log = Log;
|
|
28527
28558
|
exports.addTime = addTime;
|
|
@@ -28550,6 +28581,7 @@ exports.isNullOrUndefined = isNullOrUndefined;
|
|
|
28550
28581
|
exports.iterate = iterate;
|
|
28551
28582
|
exports.joinPath = joinPath;
|
|
28552
28583
|
exports.jsonDistinct = jsonDistinct;
|
|
28584
|
+
exports.jsonSerialize = jsonSerialize;
|
|
28553
28585
|
exports.last = last;
|
|
28554
28586
|
exports.logMemoryUsage = logMemoryUsage;
|
|
28555
28587
|
exports.mapOrThrow = mapOrThrow;
|
|
@@ -28559,6 +28591,7 @@ exports.notNull = notNull;
|
|
|
28559
28591
|
exports.notUndefined = notUndefined;
|
|
28560
28592
|
exports.pluralize = pluralize;
|
|
28561
28593
|
exports.processArrayDifferences = processArrayDifferences;
|
|
28594
|
+
exports.processArrayItemMove = processArrayItemMove;
|
|
28562
28595
|
exports.range = range;
|
|
28563
28596
|
exports.removeUndefinedProps = removeUndefinedProps;
|
|
28564
28597
|
exports.selectMany = selectMany;
|