@zelgadis87/utils-core 5.1.0 → 5.1.2
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
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { TFunction } from "../_index";
|
|
2
2
|
|
|
3
|
-
export function dictToEntries<V, K extends string = string>( obj: Record<K, V> ): [K, V][] {
|
|
4
|
-
return Object.entries( obj ) as [K, V][];
|
|
3
|
+
export function dictToEntries<V, K extends string = string>( obj: Record<K, V> ): [ K, V ][] {
|
|
4
|
+
return Object.entries( obj ) as [ K, V ][];
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export function entriesToDict<V, K extends string = string>( entries: [K, V][] ): Record<K, V> {
|
|
7
|
+
export function entriesToDict<V, K extends string = string>( entries: [ K, V ][] ): Record<K, V> {
|
|
8
8
|
return Object.fromEntries( entries ) as Record<K, V>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export function
|
|
11
|
+
export function entriesToEntries<K1 extends string, V1, K2 extends string, V2>( dict: Record<K1, V1>, mapper: TFunction<[ K1, V1 ], [ K2, V2 ]> ): Record<K2, V2> {
|
|
12
12
|
return entriesToDict( dictToEntries( dict ).map( ( entry ) => mapper( entry ) ) );
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
/** @deprecated[2025.08.01]: Compatibility layer. */
|
|
16
|
+
export const mapEntries = entriesToEntries;
|
|
17
|
+
|
|
18
|
+
export function entriesToList<K1 extends string, V1, R>( dict: Record<K1, V1>, mapper: TFunction<[ K1, V1 ], R> ): Array<R> {
|
|
19
|
+
return dictToEntries( dict ).map( ( entry ) => mapper( entry ) );
|
|
20
|
+
}
|