@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
|
@@ -1 +1 @@
|
|
|
1
|
-
export { processArrayDifferences } from "./arrays";
|
|
1
|
+
export { processArrayDifferences, processArrayItemMove } from "./arrays";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
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`;
|
|
@@ -28513,6 +28531,19 @@ const processArrayDifferences = ({ elements, elementIdSelector, desiredItems, de
|
|
|
28513
28531
|
correspondingElements,
|
|
28514
28532
|
};
|
|
28515
28533
|
};
|
|
28534
|
+
const processArrayItemMove = (items, input) => {
|
|
28535
|
+
const { oldIndex, newIndex } = input;
|
|
28536
|
+
const item = items[oldIndex];
|
|
28537
|
+
const newItems = [...items];
|
|
28538
|
+
newItems.splice(oldIndex, 1);
|
|
28539
|
+
newItems.splice(newIndex, 0, item);
|
|
28540
|
+
return newItems.map((x, i) => ({
|
|
28541
|
+
item: x,
|
|
28542
|
+
newIndex: i,
|
|
28543
|
+
oldIndex: items.indexOf(x),
|
|
28544
|
+
isMoved: i !== items.indexOf(x),
|
|
28545
|
+
}));
|
|
28546
|
+
};
|
|
28516
28547
|
|
|
28517
|
-
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, 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 };
|
|
28518
28549
|
//# sourceMappingURL=index.js.map
|