utilium 1.2.5 → 1.2.7

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/objects.d.ts CHANGED
@@ -19,6 +19,16 @@ export type Entries<T extends object> = ({
19
19
  }[keyof T] & unknown[])[];
20
20
  export declare function isJSON(str: string): boolean;
21
21
  export declare function resolveConstructors(object: object): string[];
22
+ /**
23
+ * Allows you to convert an object with specific member types into a Map that will give you the correct type for the correct member
24
+ */
25
+ export interface ConstMap<T extends Partial<Record<keyof any, any>>, K extends keyof any = keyof T, V = T[keyof T]> extends Map<K, V> {
26
+ get<TK extends keyof T>(key: TK): T[TK];
27
+ get(key: K): V;
28
+ set<TK extends keyof T>(key: TK, value: T[TK]): this;
29
+ set(key: K, value: V): this;
30
+ has(key: keyof T | K): boolean;
31
+ }
22
32
  export declare function map<const T extends Partial<Record<any, any>>>(items: T): Map<keyof T, T[keyof T]>;
23
33
  export declare function getByString(object: Record<string, any>, path: string, separator?: RegExp): Record<string, any>;
24
34
  export declare function setByString(object: Record<string, any>, path: string, value: unknown, separator?: RegExp): Record<string, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utilium",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "Typescript utilities",
5
5
  "funding": {
6
6
  "type": "individual",
package/src/objects.ts CHANGED
@@ -61,6 +61,17 @@ export function resolveConstructors(object: object): string[] {
61
61
  return constructors;
62
62
  }
63
63
 
64
+ /**
65
+ * Allows you to convert an object with specific member types into a Map that will give you the correct type for the correct member
66
+ */
67
+ export interface ConstMap<T extends Partial<Record<keyof any, any>>, K extends keyof any = keyof T, V = T[keyof T]> extends Map<K, V> {
68
+ get<TK extends keyof T>(key: TK): T[TK];
69
+ get(key: K): V;
70
+ set<TK extends keyof T>(key: TK, value: T[TK]): this;
71
+ set(key: K, value: V): this;
72
+ has(key: keyof T | K): boolean;
73
+ }
74
+
64
75
  export function map<const T extends Partial<Record<any, any>>>(items: T): Map<keyof T, T[keyof T]> {
65
76
  return new Map(Object.entries(items) as [keyof T, T[keyof T]][]);
66
77
  }