@zelgadis87/utils-core 4.3.3 → 4.3.4
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/package.json +1 -1
- package/src/utils/groupBy.ts +8 -0
package/package.json
CHANGED
package/src/utils/groupBy.ts
CHANGED
|
@@ -9,6 +9,10 @@ export function groupByNumber<V, K extends TKeysOfType<V, number>>( arr: V[], fi
|
|
|
9
9
|
return groupByNumberWith( arr, t => t[ field ] as number );
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export function groupByBoolean<V, K extends TKeysOfType<V, boolean>>( arr: V[], field: K ): Record<"true" | "false", V[]> {
|
|
13
|
+
return groupByBooleanWith( arr, t => t[ field ] as boolean );
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
export function groupBySymbol<V, K extends TKeysOfType<V, symbol>>( arr: V[], field: K ): Record<V[K] & symbol, V[]> {
|
|
13
17
|
return groupBySymbolWith( arr, t => t[ field ] as symbol );
|
|
14
18
|
}
|
|
@@ -21,6 +25,10 @@ export function groupByNumberWith<V, K extends number>( arr: V[], getter: TFunct
|
|
|
21
25
|
return doGroupByWith<K, V>( arr, getter );
|
|
22
26
|
}
|
|
23
27
|
|
|
28
|
+
export function groupByBooleanWith<V, K extends boolean>( arr: V[], getter: TFunction<V, K> ): Record<"true" | "false", V[]> {
|
|
29
|
+
return doGroupByWith<"true" | "false", V>( arr, item => getter( item ) ? "true" : "false" );
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
export function groupBySymbolWith<V, K extends symbol>( arr: V[], getter: TFunction<V, K> ): Record<K, V[]> {
|
|
25
33
|
return doGroupByWith<K, V>( arr, getter );
|
|
26
34
|
}
|