getorset-anything 0.0.2 → 0.0.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/README.md CHANGED
@@ -38,10 +38,9 @@ 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
- const arr = mapGetOrSet(map, 'abc', () => [])
43
+ const arr = mapGetOrSet(map, 'abc', (): number[] => [])
45
44
 
46
45
  arr.push(100) // OK!
47
46
  ```
@@ -51,10 +50,9 @@ Objects
51
50
  ```ts
52
51
  import { objGetOrSet } from 'getorset-anything'
53
52
 
54
-
55
53
  const obj: Record<string, number[]> = {}
56
54
 
57
- const arr = objGetOrSet(obj, 'abc', () => [])
55
+ const arr = objGetOrSet(obj, 'abc', (): number[] => [])
58
56
 
59
57
  arr.push(100) // OK!
60
58
  ```
@@ -75,12 +73,17 @@ arr.push(100) // OK!
75
73
  arr.push('100') // NG! ⛔️
76
74
  ```
77
75
 
78
- ## Meet the family
76
+ ## Meet the family (more tiny utils with TS support)
79
77
 
78
+ - [is-what 🙉](https://github.com/mesqueeb/is-what)
79
+ - [is-where 🙈](https://github.com/mesqueeb/is-where)
80
80
  - [merge-anything 🥡](https://github.com/mesqueeb/merge-anything)
81
+ - [check-anything 👁](https://github.com/mesqueeb/check-anything)
82
+ - [remove-anything ✂️](https://github.com/mesqueeb/remove-anything)
83
+ - [getorset-anything 🐊](https://github.com/mesqueeb/getorset-anything)
84
+ - [map-anything 🗺](https://github.com/mesqueeb/map-anything)
81
85
  - [filter-anything ⚔️](https://github.com/mesqueeb/filter-anything)
82
- - [find-and-replace-anything 🎣](https://github.com/mesqueeb/find-and-replace-anything)
83
- - [compare-anything 🛰](https://github.com/mesqueeb/compare-anything)
84
86
  - [copy-anything 🎭](https://github.com/mesqueeb/copy-anything)
87
+ - [case-anything 🐫](https://github.com/mesqueeb/case-anything)
85
88
  - [flatten-anything 🏏](https://github.com/mesqueeb/flatten-anything)
86
- - [is-what 🙉](https://github.com/mesqueeb/is-what)
89
+ - [nestify-anything 🧅](https://github.com/mesqueeb/nestify-anything)
package/dist/index.cjs CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  /**
6
4
  * Retrieve the value in a map, or if it wasn't found, set an initial value and return that.
7
5
  *
@@ -1,5 +1,5 @@
1
- declare type KeyOfMap<M extends Map<unknown, unknown>> = M extends Map<infer K, unknown> ? K : never;
2
- declare type ValueOfMap<M extends Map<unknown, unknown>> = M extends Map<unknown, infer V> ? V : never;
1
+ type KeyOfMap<M extends Map<unknown, unknown>> = M extends Map<infer K, unknown> ? K : never;
2
+ type ValueOfMap<M extends Map<unknown, unknown>> = M extends Map<unknown, infer V> ? V : never;
3
3
  /**
4
4
  * Retrieve the value in a map, or if it wasn't found, set an initial value and return that.
5
5
  *
@@ -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.4",
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.",
@@ -9,9 +9,9 @@
9
9
  "types": "./dist/types/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
+ "types": "./dist/types/index.d.ts",
12
13
  "import": "./dist/index.es.js",
13
- "require": "./dist/index.cjs",
14
- "types": "./dist/types/index.d.ts"
14
+ "require": "./dist/index.cjs"
15
15
  }
16
16
  },
17
17
  "files": [
@@ -24,8 +24,8 @@
24
24
  "clean": "del ./dist",
25
25
  "lint": "tsc --noEmit && eslint ./src --ext .ts",
26
26
  "test": "vitest run",
27
- "build": "npm run clean && rollup -c ./scripts/build.js",
28
- "release": "npm run lint && del dist && npm run build && np"
27
+ "build": "rollup --bundleConfigAsCjs -c ./scripts/build.js",
28
+ "release": "npm run lint && npm run clean && npm run build && np"
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",
@@ -60,18 +60,18 @@
60
60
  "homepage": "https://github.com/mesqueeb/getorset-anything#readme",
61
61
  "dependencies": {},
62
62
  "devDependencies": {
63
- "@typescript-eslint/eslint-plugin": "^5.10.1",
64
- "@typescript-eslint/parser": "^5.10.1",
63
+ "@typescript-eslint/eslint-plugin": "^5.59.2",
64
+ "@typescript-eslint/parser": "^5.59.2",
65
65
  "del-cli": "^4.0.1",
66
- "eslint": "^8.7.0",
67
- "eslint-config-prettier": "^8.3.0",
66
+ "eslint": "^8.40.0",
67
+ "eslint-config-prettier": "^8.8.0",
68
68
  "eslint-plugin-tree-shaking": "^1.10.0",
69
- "np": "^7.6.0",
70
- "prettier": "^2.5.1",
71
- "rollup": "^2.66.1",
72
- "rollup-plugin-typescript2": "^0.31.1",
73
- "typescript": "^4.5.5",
74
- "vitest": "^0.2.3"
69
+ "np": "^7.7.0",
70
+ "prettier": "^2.8.8",
71
+ "rollup": "^3.21.5",
72
+ "rollup-plugin-typescript2": "^0.34.1",
73
+ "typescript": "^4.9.5",
74
+ "vitest": "^0.31.0"
75
75
  },
76
76
  "np": {
77
77
  "yarn": false,