@punks/backend-core 0.0.56 → 0.0.57
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,6 +5,7 @@ export interface Dict<TVal> {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const toDict: <TVal>(array: TVal[], keySelector: (value: TVal) => string) => Dict<TVal>;
|
|
7
7
|
export declare const toItemsDict: <TItem, TVal>(array: TItem[], keySelector: (value: TItem) => string, elementSelector: (value: TItem) => TVal) => Dict<TVal>;
|
|
8
|
+
export declare const toArrayDict: <TVal>(array: TVal[], keySelector: (value: TVal) => string) => Dict<TVal[]>;
|
|
8
9
|
export declare const toMap: <TKey, TVal>(array: TVal[], key: (val: TVal) => TKey) => Map<TKey, TVal>;
|
|
9
10
|
export declare const toItemsMap: <TItem, TKey, TVal>(array: TItem[], key: (val: TItem) => TKey, element: (val: TItem) => TVal) => Map<TKey, TVal>;
|
|
10
11
|
export declare const last: <T>(arr: T[]) => T;
|
package/dist/esm/index.js
CHANGED
|
@@ -35,6 +35,17 @@ const toItemsDict = (array, keySelector, elementSelector) => {
|
|
|
35
35
|
}
|
|
36
36
|
return data;
|
|
37
37
|
};
|
|
38
|
+
const toArrayDict = (array, keySelector) => {
|
|
39
|
+
const data = {};
|
|
40
|
+
for (const item of array) {
|
|
41
|
+
const key = keySelector(item);
|
|
42
|
+
if (!data[key]) {
|
|
43
|
+
data[key] = [];
|
|
44
|
+
}
|
|
45
|
+
data[key].push(item);
|
|
46
|
+
}
|
|
47
|
+
return data;
|
|
48
|
+
};
|
|
38
49
|
const toMap = (array, key) => {
|
|
39
50
|
const map = new Map();
|
|
40
51
|
array.forEach((x) => map.set(key(x), x));
|
|
@@ -28620,5 +28631,5 @@ const processArrayItemMove = (items, input) => {
|
|
|
28620
28631
|
}));
|
|
28621
28632
|
};
|
|
28622
28633
|
|
|
28623
|
-
export { ConsoleLogger, DatadogLogger, 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 };
|
|
28634
|
+
export { ConsoleLogger, DatadogLogger, 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, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart };
|
|
28624
28635
|
//# sourceMappingURL=index.js.map
|