getorset-anything 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -38,7 +38,6 @@ Maps
38
38
  ```ts
39
39
  import { mapGetOrSet } from 'getorset-anything'
40
40
 
41
-
42
41
  const map = new Map<string, number[]>()
43
42
 
44
43
  const arr = mapGetOrSet(map, 'abc', () => [])
@@ -51,7 +50,6 @@ Objects
51
50
  ```ts
52
51
  import { objGetOrSet } from 'getorset-anything'
53
52
 
54
-
55
53
  const obj: Record<string, number[]> = {}
56
54
 
57
55
  const arr = objGetOrSet(obj, 'abc', () => [])
@@ -12,7 +12,7 @@ declare type ValueOfMap<M extends Map<unknown, unknown>> = M extends Map<unknown
12
12
  * arr.push('xyz')
13
13
  * ```
14
14
  */
15
- export declare function mapGetOrSet<M extends Map<unknown, unknown>>(map: M, key: KeyOfMap<M>, initialValue: () => ValueOfMap<M>): ValueOfMap<M>;
15
+ export declare function mapGetOrSet<M extends Map<unknown, unknown>, T extends () => ValueOfMap<M>>(map: M, key: KeyOfMap<M>, initialValue: T): ReturnType<T>;
16
16
  /**
17
17
  * Retrieve the value in an object, or if it wasn't found, set an initial value and return that.
18
18
  *
@@ -25,5 +25,5 @@ export declare function mapGetOrSet<M extends Map<unknown, unknown>>(map: M, key
25
25
  * arr.push('xyz')
26
26
  * ```
27
27
  */
28
- export declare function objGetOrSet<O extends Record<string | number | symbol, unknown>>(obj: O, key: keyof O, initialValue: () => O[keyof O]): O[keyof O];
28
+ export declare function objGetOrSet<O extends Record<string | number | symbol, unknown>, T extends () => O[keyof O]>(obj: O, key: keyof O, initialValue: T): ReturnType<T>;
29
29
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "getorset-anything",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "sideEffects": false,
5
5
  "type": "module",
6
6
  "description": "Gets a value from a Map/Obj or sets an initial value when not found and returns that. TypeScript supported.",