@oscarpalmer/atoms 0.77.2 → 0.78.0

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.
Files changed (175) hide show
  1. package/README.md +2 -2
  2. package/package.json +39 -78
  3. package/src/{js/array → array}/group-by.ts +10 -9
  4. package/src/{js/array → array}/to-map.ts +20 -20
  5. package/src/{js/array → array}/to-record.ts +59 -58
  6. package/types/array/group-by.d.cts +69 -9
  7. package/types/array/group-by.d.ts +10 -9
  8. package/types/array/index.d.cts +87 -27
  9. package/types/array/to-map.d.cts +10 -11
  10. package/types/array/to-map.d.ts +11 -11
  11. package/types/array/to-record.d.cts +68 -8
  12. package/types/array/to-record.d.ts +9 -8
  13. package/types/index.d.cts +41 -39
  14. package/dist/css/a11y.css +0 -13
  15. package/dist/css/flex.css +0 -150
  16. package/dist/css/reset.css +0 -316
  17. package/src/css/a11y.scss +0 -16
  18. package/src/css/flex.scss +0 -104
  19. package/src/css/reset.scss +0 -323
  20. /package/dist/{js/array → array}/chunk.cjs +0 -0
  21. /package/dist/{js/array → array}/chunk.js +0 -0
  22. /package/dist/{js/array → array}/compact.cjs +0 -0
  23. /package/dist/{js/array → array}/compact.js +0 -0
  24. /package/dist/{js/array → array}/count.cjs +0 -0
  25. /package/dist/{js/array → array}/count.js +0 -0
  26. /package/dist/{js/array → array}/exists.cjs +0 -0
  27. /package/dist/{js/array → array}/exists.js +0 -0
  28. /package/dist/{js/array → array}/filter.cjs +0 -0
  29. /package/dist/{js/array → array}/filter.js +0 -0
  30. /package/dist/{js/array → array}/find.cjs +0 -0
  31. /package/dist/{js/array → array}/find.js +0 -0
  32. /package/dist/{js/array → array}/group-by.cjs +0 -0
  33. /package/dist/{js/array → array}/group-by.js +0 -0
  34. /package/dist/{js/array → array}/index-of.cjs +0 -0
  35. /package/dist/{js/array → array}/index-of.js +0 -0
  36. /package/dist/{js/array → array}/index.cjs +0 -0
  37. /package/dist/{js/array → array}/index.js +0 -0
  38. /package/dist/{js/array → array}/insert.cjs +0 -0
  39. /package/dist/{js/array → array}/insert.js +0 -0
  40. /package/dist/{js/array → array}/models.cjs +0 -0
  41. /package/dist/{js/array → array}/models.js +0 -0
  42. /package/dist/{js/array → array}/shuffle.cjs +0 -0
  43. /package/dist/{js/array → array}/shuffle.js +0 -0
  44. /package/dist/{js/array → array}/sort.cjs +0 -0
  45. /package/dist/{js/array → array}/sort.js +0 -0
  46. /package/dist/{js/array → array}/splice.cjs +0 -0
  47. /package/dist/{js/array → array}/splice.js +0 -0
  48. /package/dist/{js/array → array}/to-map.cjs +0 -0
  49. /package/dist/{js/array → array}/to-map.js +0 -0
  50. /package/dist/{js/array → array}/to-record.cjs +0 -0
  51. /package/dist/{js/array → array}/to-record.js +0 -0
  52. /package/dist/{js/array → array}/unique.cjs +0 -0
  53. /package/dist/{js/array → array}/unique.js +0 -0
  54. /package/dist/{js/colour → colour}/base.cjs +0 -0
  55. /package/dist/{js/colour → colour}/base.js +0 -0
  56. /package/dist/{js/colour → colour}/functions.cjs +0 -0
  57. /package/dist/{js/colour → colour}/functions.js +0 -0
  58. /package/dist/{js/colour → colour}/hex.cjs +0 -0
  59. /package/dist/{js/colour → colour}/hex.js +0 -0
  60. /package/dist/{js/colour → colour}/hsl.cjs +0 -0
  61. /package/dist/{js/colour → colour}/hsl.js +0 -0
  62. /package/dist/{js/colour → colour}/index.cjs +0 -0
  63. /package/dist/{js/colour → colour}/index.js +0 -0
  64. /package/dist/{js/colour → colour}/is.cjs +0 -0
  65. /package/dist/{js/colour → colour}/is.js +0 -0
  66. /package/dist/{js/colour → colour}/rgb.cjs +0 -0
  67. /package/dist/{js/colour → colour}/rgb.js +0 -0
  68. /package/dist/{js/emitter.cjs → emitter.cjs} +0 -0
  69. /package/dist/{js/emitter.js → emitter.js} +0 -0
  70. /package/dist/{js/function.cjs → function.cjs} +0 -0
  71. /package/dist/{js/function.js → function.js} +0 -0
  72. /package/dist/{js/index.cjs → index.cjs} +0 -0
  73. /package/dist/{js/index.js → index.js} +0 -0
  74. /package/dist/{js/internal → internal}/array/callbacks.cjs +0 -0
  75. /package/dist/{js/internal → internal}/array/callbacks.js +0 -0
  76. /package/dist/{js/internal → internal}/array/find.cjs +0 -0
  77. /package/dist/{js/internal → internal}/array/find.js +0 -0
  78. /package/dist/{js/internal → internal}/value/handle.cjs +0 -0
  79. /package/dist/{js/internal → internal}/value/handle.js +0 -0
  80. /package/dist/{js/is.cjs → is.cjs} +0 -0
  81. /package/dist/{js/is.js → is.js} +0 -0
  82. /package/dist/{js/logger.cjs → logger.cjs} +0 -0
  83. /package/dist/{js/logger.js → logger.js} +0 -0
  84. /package/dist/{js/math.cjs → math.cjs} +0 -0
  85. /package/dist/{js/math.js → math.js} +0 -0
  86. /package/dist/{js/models.cjs → models.cjs} +0 -0
  87. /package/dist/{js/models.js → models.js} +0 -0
  88. /package/dist/{js/number.cjs → number.cjs} +0 -0
  89. /package/dist/{js/number.js → number.js} +0 -0
  90. /package/dist/{js/query.cjs → query.cjs} +0 -0
  91. /package/dist/{js/query.js → query.js} +0 -0
  92. /package/dist/{js/queue.cjs → queue.cjs} +0 -0
  93. /package/dist/{js/queue.js → queue.js} +0 -0
  94. /package/dist/{js/random.cjs → random.cjs} +0 -0
  95. /package/dist/{js/random.js → random.js} +0 -0
  96. /package/dist/{js/sized.cjs → sized.cjs} +0 -0
  97. /package/dist/{js/sized.js → sized.js} +0 -0
  98. /package/dist/{js/string → string}/case.cjs +0 -0
  99. /package/dist/{js/string → string}/case.js +0 -0
  100. /package/dist/{js/string → string}/index.cjs +0 -0
  101. /package/dist/{js/string → string}/index.js +0 -0
  102. /package/dist/{js/string → string}/template.cjs +0 -0
  103. /package/dist/{js/string → string}/template.js +0 -0
  104. /package/dist/{js/touch.cjs → touch.cjs} +0 -0
  105. /package/dist/{js/touch.js → touch.js} +0 -0
  106. /package/dist/{js/value → value}/clone.cjs +0 -0
  107. /package/dist/{js/value → value}/clone.js +0 -0
  108. /package/dist/{js/value → value}/compare.cjs +0 -0
  109. /package/dist/{js/value → value}/compare.js +0 -0
  110. /package/dist/{js/value → value}/diff.cjs +0 -0
  111. /package/dist/{js/value → value}/diff.js +0 -0
  112. /package/dist/{js/value → value}/equal.cjs +0 -0
  113. /package/dist/{js/value → value}/equal.js +0 -0
  114. /package/dist/{js/value → value}/get.cjs +0 -0
  115. /package/dist/{js/value → value}/get.js +0 -0
  116. /package/dist/{js/value → value}/index.cjs +0 -0
  117. /package/dist/{js/value → value}/index.js +0 -0
  118. /package/dist/{js/value → value}/merge.cjs +0 -0
  119. /package/dist/{js/value → value}/merge.js +0 -0
  120. /package/dist/{js/value → value}/set.cjs +0 -0
  121. /package/dist/{js/value → value}/set.js +0 -0
  122. /package/dist/{js/value → value}/smush.cjs +0 -0
  123. /package/dist/{js/value → value}/smush.js +0 -0
  124. /package/dist/{js/value → value}/unsmush.cjs +0 -0
  125. /package/dist/{js/value → value}/unsmush.js +0 -0
  126. /package/src/{js/array → array}/chunk.ts +0 -0
  127. /package/src/{js/array → array}/compact.ts +0 -0
  128. /package/src/{js/array → array}/count.ts +0 -0
  129. /package/src/{js/array → array}/exists.ts +0 -0
  130. /package/src/{js/array → array}/filter.ts +0 -0
  131. /package/src/{js/array → array}/find.ts +0 -0
  132. /package/src/{js/array → array}/index-of.ts +0 -0
  133. /package/src/{js/array → array}/index.ts +0 -0
  134. /package/src/{js/array → array}/insert.ts +0 -0
  135. /package/src/{js/array → array}/models.ts +0 -0
  136. /package/src/{js/array → array}/shuffle.ts +0 -0
  137. /package/src/{js/array → array}/sort.ts +0 -0
  138. /package/src/{js/array → array}/splice.ts +0 -0
  139. /package/src/{js/array → array}/unique.ts +0 -0
  140. /package/src/{js/colour → colour}/base.ts +0 -0
  141. /package/src/{js/colour → colour}/functions.ts +0 -0
  142. /package/src/{js/colour → colour}/hex.ts +0 -0
  143. /package/src/{js/colour → colour}/hsl.ts +0 -0
  144. /package/src/{js/colour → colour}/index.ts +0 -0
  145. /package/src/{js/colour → colour}/is.ts +0 -0
  146. /package/src/{js/colour → colour}/rgb.ts +0 -0
  147. /package/src/{js/emitter.ts → emitter.ts} +0 -0
  148. /package/src/{js/function.ts → function.ts} +0 -0
  149. /package/src/{js/index.ts → index.ts} +0 -0
  150. /package/src/{js/internal → internal}/array/callbacks.ts +0 -0
  151. /package/src/{js/internal → internal}/array/find.ts +0 -0
  152. /package/src/{js/internal → internal}/value/handle.ts +0 -0
  153. /package/src/{js/is.ts → is.ts} +0 -0
  154. /package/src/{js/logger.ts → logger.ts} +0 -0
  155. /package/src/{js/math.ts → math.ts} +0 -0
  156. /package/src/{js/models.ts → models.ts} +0 -0
  157. /package/src/{js/number.ts → number.ts} +0 -0
  158. /package/src/{js/query.ts → query.ts} +0 -0
  159. /package/src/{js/queue.ts → queue.ts} +0 -0
  160. /package/src/{js/random.ts → random.ts} +0 -0
  161. /package/src/{js/sized.ts → sized.ts} +0 -0
  162. /package/src/{js/string → string}/case.ts +0 -0
  163. /package/src/{js/string → string}/index.ts +0 -0
  164. /package/src/{js/string → string}/template.ts +0 -0
  165. /package/src/{js/touch.ts → touch.ts} +0 -0
  166. /package/src/{js/value → value}/clone.ts +0 -0
  167. /package/src/{js/value → value}/compare.ts +0 -0
  168. /package/src/{js/value → value}/diff.ts +0 -0
  169. /package/src/{js/value → value}/equal.ts +0 -0
  170. /package/src/{js/value → value}/get.ts +0 -0
  171. /package/src/{js/value → value}/index.ts +0 -0
  172. /package/src/{js/value → value}/merge.ts +0 -0
  173. /package/src/{js/value → value}/set.ts +0 -0
  174. /package/src/{js/value → value}/smush.ts +0 -0
  175. /package/src/{js/value → value}/unsmush.ts +0 -0
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Atoms
2
2
 
3
- [![npm](https://badge.fury.io/js/@oscarpalmer%2Fatoms.svg)](https://www.npmjs.com/package/@oscarpalmer/atoms)
3
+ [![npm](https://badge.fury.io/js/@oscarpalmer%2Fatoms.svg)](https://www.npmjs.com/package/@oscarpalmer/atoms) [![Tests](https://github.com/oscarpalmer/atoms/actions/workflows/test.yml/badge.svg)](https://github.com/oscarpalmer/atoms/actions/workflows/test.yml)
4
4
 
5
- Sweet little atomic goodies…
5
+ Atomic utilities for making your _JavaScript_ better.
6
6
 
7
7
  ## License
8
8
 
package/package.json CHANGED
@@ -6,15 +6,14 @@
6
6
  "dependencies": {
7
7
  "type-fest": "^4.26"
8
8
  },
9
- "description": "Sweet little atomic goodies…",
9
+ "description": "Atomic utilities for making your JavaScript better.",
10
10
  "devDependencies": {
11
11
  "@biomejs/biome": "^1.9",
12
- "@types/node": "^22.7",
12
+ "@types/node": "^22.8",
13
13
  "@vitest/coverage-istanbul": "^2.1",
14
14
  "dts-bundle-generator": "^9.5",
15
15
  "glob": "^11",
16
16
  "happy-dom": "^15.7",
17
- "sass": "^1.79",
18
17
  "typescript": "^5.6",
19
18
  "vite": "^5.4",
20
19
  "vitest": "^2.1"
@@ -22,107 +21,86 @@
22
21
  "exports": {
23
22
  "./package.json": "./package.json",
24
23
  ".": {
25
- "bun": "./src/js/index.ts",
26
24
  "import": {
27
25
  "types": "./types/index.d.ts",
28
- "default": "./dist/js/index.js"
26
+ "default": "./dist/index.js"
29
27
  },
30
28
  "require": {
31
29
  "types": "./types/index.d.cts",
32
- "default": "./dist/js/index.cjs"
30
+ "default": "./dist/index.cjs"
33
31
  }
34
32
  },
35
33
  "./array": {
36
- "bun": "./src/js/array/index.ts",
37
34
  "import": {
38
35
  "types": "./types/array/index.d.ts",
39
- "default": "./dist/js/array/index.js"
36
+ "default": "./dist/array/index.js"
40
37
  },
41
38
  "require": {
42
39
  "types": "./types/array/index.d.cts",
43
- "default": "./dist/js/array/index.cjs"
40
+ "default": "./dist/array/index.cjs"
44
41
  }
45
42
  },
46
43
  "./colour": {
47
- "bun": "./src/js/colour/index.ts",
48
44
  "import": {
49
45
  "types": "./types/colour/index.d.ts",
50
- "default": "./dist/js/colour/index.js"
46
+ "default": "./dist/colour/index.js"
51
47
  },
52
48
  "require": {
53
49
  "types": "./types/colour/index.d.cts",
54
- "default": "./dist/js/colour/index.cjs"
50
+ "default": "./dist/colour/index.cjs"
55
51
  }
56
52
  },
57
- "./css/a11y": {
58
- "sass": "./src/css/a11y.scss",
59
- "style": "./dist/css/a11y.css"
60
- },
61
- "./css/flex": {
62
- "sass": "./src/css/flex.scss",
63
- "style": "./dist/css/flex.css"
64
- },
65
- "./css/reset": {
66
- "sass": "./src/css/reset.scss",
67
- "style": "./dist/css/reset.css"
68
- },
69
53
  "./emitter": {
70
- "bun": "./src/js/emitter.ts",
71
54
  "import": {
72
55
  "types": "./types/emitter.d.ts",
73
- "default": "./dist/js/emitter.js"
56
+ "default": "./dist/emitter.js"
74
57
  },
75
58
  "require": {
76
59
  "types": "./types/emitter.d.cts",
77
- "default": "./dist/js/emitter.cjs"
60
+ "default": "./dist/emitter.cjs"
78
61
  }
79
62
  },
80
63
  "./function": {
81
- "bun": "./src/js/function.ts",
82
64
  "import": {
83
65
  "types": "./types/function.d.ts",
84
- "default": "./dist/js/function.js"
66
+ "default": "./dist/function.js"
85
67
  },
86
68
  "require": {
87
69
  "types": "./types/function.d.cts",
88
- "default": "./dist/js/function.cjs"
70
+ "default": "./dist/function.cjs"
89
71
  }
90
72
  },
91
73
  "./is": {
92
- "bun": "./src/js/is.ts",
93
74
  "import": {
94
75
  "types": "./types/is.d.ts",
95
- "default": "./dist/js/is.js"
76
+ "default": "./dist/is.js"
96
77
  },
97
78
  "require": {
98
79
  "types": "./types/is.d.cts",
99
- "default": "./dist/js/is.cjs"
80
+ "default": "./dist/is.cjs"
100
81
  }
101
82
  },
102
83
  "./logger": {
103
- "bun": "./src/js/logger.ts",
104
84
  "import": {
105
85
  "types": "./types/logger.d.ts",
106
- "default": "./dist/js/logger.js"
86
+ "default": "./dist/logger.js"
107
87
  },
108
88
  "require": {
109
89
  "types": "./types/logger.d.cts",
110
- "default": "./dist/js/logger.cjs"
90
+ "default": "./dist/logger.cjs"
111
91
  }
112
92
  },
113
93
  "./math": {
114
- "bun": "./src/js/math.ts",
115
94
  "import": {
116
95
  "types": "./types/math.d.ts",
117
- "default": "./dist/js/math.js"
96
+ "default": "./dist/math.js"
118
97
  },
119
98
  "require": {
120
99
  "types": "./types/math.d.cts",
121
- "default": "./dist/js/math.cjs"
100
+ "default": "./dist/math.cjs"
122
101
  }
123
102
  },
124
103
  "./models": {
125
- "bun": "./src/js/models.ts",
126
104
  "import": {
127
105
  "types": "./types/models.d.ts"
128
106
  },
@@ -131,111 +109,94 @@
131
109
  }
132
110
  },
133
111
  "./number": {
134
- "bun": "./src/js/number.ts",
135
112
  "import": {
136
113
  "types": "./types/number.d.ts",
137
- "default": "./dist/js/number.js"
114
+ "default": "./dist/number.js"
138
115
  },
139
116
  "require": {
140
117
  "types": "./types/number.d.cts",
141
- "default": "./dist/js/number.cjs"
118
+ "default": "./dist/number.cjs"
142
119
  }
143
120
  },
144
121
  "./query": {
145
- "bun": "./src/js/query.ts",
146
122
  "import": {
147
123
  "types": "./types/query.d.ts",
148
- "default": "./dist/js/query.js"
124
+ "default": "./dist/query.js"
149
125
  },
150
126
  "require": {
151
127
  "types": "./types/query.d.cts",
152
- "default": "./dist/js/query.cjs"
128
+ "default": "./dist/query.cjs"
153
129
  }
154
130
  },
155
131
  "./queue": {
156
- "bun": "./src/js/queue.ts",
157
132
  "import": {
158
133
  "types": "./types/queue.d.ts",
159
- "default": "./dist/js/queue.js"
134
+ "default": "./dist/queue.js"
160
135
  },
161
136
  "require": {
162
137
  "types": "./types/queue.d.cts",
163
- "default": "./dist/js/queue.cjs"
138
+ "default": "./dist/queue.cjs"
164
139
  }
165
140
  },
166
141
  "./random": {
167
- "bun": "./src/js/random.ts",
168
142
  "import": {
169
143
  "types": "./types/random.d.ts",
170
- "default": "./dist/js/random.js"
144
+ "default": "./dist/random.js"
171
145
  },
172
146
  "require": {
173
147
  "types": "./types/random.d.cts",
174
- "default": "./dist/js/random.cjs"
148
+ "default": "./dist/random.cjs"
175
149
  }
176
150
  },
177
151
  "./string": {
178
- "bun": "./src/js/string/index.ts",
179
152
  "import": {
180
153
  "types": "./types/string/index.d.ts",
181
- "default": "./dist/js/string/index.js"
154
+ "default": "./dist/string/index.js"
182
155
  },
183
156
  "require": {
184
157
  "types": "./types/string/index.d.cts",
185
- "default": "./dist/js/string/index.cjs"
158
+ "default": "./dist/string/index.cjs"
186
159
  }
187
160
  },
188
161
  "./supports-touch": {
189
- "bun": "./src/js/touch.ts",
190
162
  "import": {
191
163
  "types": "./types/touch.d.ts",
192
- "default": "./dist/js/touch.js"
164
+ "default": "./dist/touch.js"
193
165
  },
194
166
  "require": {
195
167
  "types": "./types/touch.d.cts",
196
- "default": "./dist/js/touch.cjs"
168
+ "default": "./dist/touch.cjs"
197
169
  }
198
170
  },
199
171
  "./value": {
200
- "bun": "./src/js/value/index.ts",
201
172
  "import": {
202
173
  "types": "./types/value/index.d.ts",
203
- "default": "./dist/js/value/index.js"
174
+ "default": "./dist/value/index.js"
204
175
  },
205
176
  "require": {
206
177
  "types": "./types/value/index.d.cts",
207
- "default": "./dist/js/value/index.cjs"
178
+ "default": "./dist/value/index.cjs"
208
179
  }
209
180
  }
210
181
  },
211
- "files": [
212
- "dist",
213
- "src",
214
- "types"
215
- ],
216
- "keywords": [
217
- "helper",
218
- "utility"
219
- ],
182
+ "files": ["dist", "src", "types"],
183
+ "keywords": ["helper", "utility"],
220
184
  "license": "MIT",
221
- "main": "./dist/js/index.cjs",
222
- "module": "./dist/js/index.js",
185
+ "main": "./dist/index.cjs",
186
+ "module": "./dist/index.js",
223
187
  "name": "@oscarpalmer/atoms",
224
188
  "repository": {
225
189
  "type": "git",
226
190
  "url": "git+https://github.com/oscarpalmer/atoms.git"
227
191
  },
228
192
  "scripts": {
229
- "build": "npm run clean && npm run build:css && npm run build:js",
230
- "build:css": "npx sass ./src/css:./dist/css --no-source-map",
231
- "build:js": "npx vite build && npm run types",
193
+ "build": "npm run clean && npx vite build && npm run types",
232
194
  "clean": "rm -rf ./dist && rm -rf ./types && rm -f ./tsconfig.tsbuildinfo",
233
195
  "test": "npx vitest --coverage",
234
196
  "types": "npx tsc && npx dts-bundle-generator --config ./dts.config.ts --silent",
235
- "watch:css": "npx sass ./src/css:./dist/css --no-source-map --watch",
236
- "watch:js": "npx vite build --watch"
197
+ "watch": "npx vite build --watch"
237
198
  },
238
199
  "type": "module",
239
200
  "types": "./types/index.d.cts",
240
- "version": "0.77.2"
201
+ "version": "0.78.0"
241
202
  }
@@ -1,3 +1,4 @@
1
+ import type {Simplify} from 'type-fest';
1
2
  import {getCallbacks} from '~/internal/array/callbacks';
2
3
  import type {Key, KeyedValue, PlainObject} from '~/models';
3
4
 
@@ -7,7 +8,7 @@ import type {Key, KeyedValue, PlainObject} from '~/models';
7
8
  export function groupBy<Item extends PlainObject, ItemKey extends keyof Item>(
8
9
  array: Item[],
9
10
  key: ItemKey,
10
- ): Record<KeyedValue<Item, ItemKey>, Item>;
11
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Item>>;
11
12
 
12
13
  /**
13
14
  * Create a record from an array of items using a specific key, and grouping them into arrays
@@ -16,7 +17,7 @@ export function groupBy<Item extends PlainObject, ItemKey extends keyof Item>(
16
17
  array: Item[],
17
18
  key: ItemKey,
18
19
  arrays: true,
19
- ): Record<KeyedValue<Item, ItemKey>, Item[]>;
20
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Item[]>>;
20
21
 
21
22
  /**
22
23
  * Create a record from an array of items using a specific key
@@ -49,7 +50,7 @@ export function groupBy<
49
50
  array: Item[],
50
51
  key: ItemKey,
51
52
  value: ItemValue,
52
- ): Record<KeyedValue<Item, ItemKey>, KeyedValue<Item, ItemValue>>;
53
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Item[ItemValue]>>;
53
54
 
54
55
  /**
55
56
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
@@ -63,7 +64,7 @@ export function groupBy<
63
64
  key: ItemKey,
64
65
  value: ItemValue,
65
66
  arrays: true,
66
- ): Record<KeyedValue<Item, ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
67
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Array<Item[ItemValue]>>>;
67
68
 
68
69
  /**
69
70
  * Create a record from an array of items using a specific key and value
@@ -76,7 +77,7 @@ export function groupBy<
76
77
  array: Item[],
77
78
  key: ItemKey,
78
79
  value: ItemValue,
79
- ): Record<KeyedValue<Item, ItemKey>, ReturnType<ItemValue>>;
80
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, ReturnType<ItemValue>>>;
80
81
 
81
82
  /**
82
83
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
@@ -90,7 +91,7 @@ export function groupBy<
90
91
  key: ItemKey,
91
92
  value: ItemValue,
92
93
  arrays: true,
93
- ): Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ItemValue>>>;
94
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ItemValue>>>>;
94
95
 
95
96
  /**
96
97
  * Create a record from an array of items using a specific key and value
@@ -103,7 +104,7 @@ export function groupBy<
103
104
  array: Item[],
104
105
  key: ItemKey,
105
106
  value: ItemValue,
106
- ): Record<ReturnType<ItemKey>, KeyedValue<Item, ItemValue>>;
107
+ ): Record<ReturnType<ItemKey>, Item[ItemValue]>;
107
108
 
108
109
  /**
109
110
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
@@ -117,7 +118,7 @@ export function groupBy<
117
118
  key: ItemKey,
118
119
  value: ItemValue,
119
120
  arrays: true,
120
- ): Record<ReturnType<ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
121
+ ): Record<ReturnType<ItemKey>, Array<Item[ItemValue]>>;
121
122
 
122
123
  /**
123
124
  * Create a record from an array of items using a specific key and value
@@ -130,7 +131,7 @@ export function groupBy<
130
131
  array: Item[],
131
132
  key: ItemKey,
132
133
  value: ItemValue,
133
- ): Record<ReturnType<ItemKey>, ReturnType<ItemValue>>;
134
+ ): Simplify<Record<ReturnType<ItemKey>, ReturnType<ItemValue>>>;
134
135
 
135
136
  /**
136
137
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
@@ -1,5 +1,5 @@
1
1
  import {getCallbacks} from '~/internal/array/callbacks';
2
- import type {Key, KeyedValue, PlainObject} from '~/models';
2
+ import type {Key, PlainObject} from '~/models';
3
3
 
4
4
  /**
5
5
  * Create a map from an array of items _(using their indices as keys)_
@@ -12,7 +12,7 @@ export function toMap<Item>(array: Item[]): Map<number, Item>;
12
12
  export function toMap<Item extends PlainObject, ItemKey extends keyof Item>(
13
13
  array: Item[],
14
14
  key: ItemKey,
15
- ): Map<KeyedValue<Item, ItemKey>, Item>;
15
+ ): Map<Item[ItemKey], Item>;
16
16
 
17
17
  /**
18
18
  * Create a map from an array of items using a specific key, and grouping them into arrays
@@ -21,7 +21,7 @@ export function toMap<Item extends PlainObject, ItemKey extends keyof Item>(
21
21
  array: Item[],
22
22
  key: ItemKey,
23
23
  arrays: true,
24
- ): Map<KeyedValue<Item, ItemKey>, Item[]>;
24
+ ): Map<Item[ItemKey], Item[]>;
25
25
 
26
26
  /**
27
27
  * Create a map from an array of items using a specific key
@@ -50,7 +50,7 @@ export function toMap<
50
50
  array: Item[],
51
51
  key: ItemKey,
52
52
  value: ItemValue,
53
- ): Map<KeyedValue<Item, ItemKey>, KeyedValue<Item, ItemValue>>;
53
+ ): Map<Item[ItemKey], Item[ItemValue]>;
54
54
 
55
55
  /**
56
56
  * Create a map from an array of items using a specific key and value, and grouping them into arrays
@@ -64,7 +64,7 @@ export function toMap<
64
64
  key: ItemKey,
65
65
  value: ItemValue,
66
66
  arrays: true,
67
- ): Map<KeyedValue<Item, ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
67
+ ): Map<Item[ItemKey], Array<Item[ItemValue]>>;
68
68
 
69
69
  /**
70
70
  * Create a map from an array of items using a specific key and value
@@ -77,7 +77,7 @@ export function toMap<
77
77
  array: Item[],
78
78
  key: ItemKey,
79
79
  value: ItemValue,
80
- ): Map<KeyedValue<Item, ItemKey>, ReturnType<ItemValue>>;
80
+ ): Map<Item[ItemKey], ReturnType<ItemValue>>;
81
81
 
82
82
  /**
83
83
  * Create a map from an array of items using a specific key and value, and grouping them into arrays
@@ -91,7 +91,7 @@ export function toMap<
91
91
  key: ItemKey,
92
92
  value: ItemValue,
93
93
  arrays: true,
94
- ): Map<KeyedValue<Item, ItemKey>, Array<ReturnType<ItemValue>>>;
94
+ ): Map<Item[ItemKey], Array<ReturnType<ItemValue>>>;
95
95
 
96
96
  /**
97
97
  * Create a map from an array of items using a specific key and value
@@ -104,7 +104,7 @@ export function toMap<
104
104
  array: Item[],
105
105
  key: ItemKey,
106
106
  value: ItemValue,
107
- ): Map<ReturnType<ItemKey>, KeyedValue<Item, ItemValue>>;
107
+ ): Map<ReturnType<ItemKey>, Item[ItemValue]>;
108
108
 
109
109
  /**
110
110
  * Create a map from an array of items using a specific key and value, and grouping them into arrays
@@ -118,41 +118,41 @@ export function toMap<
118
118
  key: ItemKey,
119
119
  value: ItemValue,
120
120
  arrays: true,
121
- ): Map<ReturnType<ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
121
+ ): Map<ReturnType<ItemKey>, Array<Item[ItemValue]>>;
122
122
 
123
123
  /**
124
124
  * Create a map from an array of items using a specific key and value
125
125
  */
126
126
  export function toMap<
127
127
  Item,
128
- Key extends (item: Item, index: number, array: Item[]) => Key,
129
- Value extends (item: Item, index: number, array: Item[]) => unknown,
128
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
129
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
130
130
  >(
131
131
  array: Item[],
132
- key: Key,
133
- value: Value,
134
- ): Map<ReturnType<Key>, ReturnType<Value>>;
132
+ key: ItemKey,
133
+ value: ItemValue,
134
+ ): Map<ReturnType<ItemKey>, ReturnType<ItemValue>>;
135
135
 
136
136
  /**
137
137
  * Create a map from an array of items using a specific key and value, and grouping them into arrays
138
138
  */
139
139
  export function toMap<
140
140
  Item,
141
- Key extends (item: Item, index: number, array: Item[]) => Key,
142
- Value extends (item: Item, index: number, array: Item[]) => unknown,
141
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
142
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
143
143
  >(
144
144
  array: Item[],
145
- key: Key,
146
- value: Value,
145
+ key: ItemKey,
146
+ value: ItemValue,
147
147
  arrays: true,
148
- ): Map<ReturnType<Key>, Array<ReturnType<Value>>>;
148
+ ): Map<ReturnType<ItemKey>, Array<ReturnType<ItemValue>>>;
149
149
 
150
150
  export function toMap(
151
151
  array: unknown[],
152
152
  first?: unknown,
153
153
  second?: unknown,
154
154
  third?: unknown,
155
- ): Map<Key, unknown> {
155
+ ): Map<unknown, unknown> {
156
156
  const asArrays = first === true || second === true || third === true;
157
157
  const callbacks = getCallbacks(undefined, first, second);
158
158
  const map = new Map<Key, unknown>();
@@ -1,3 +1,4 @@
1
+ import type {Simplify} from 'type-fest';
1
2
  import {groupValues} from '~/array/group-by';
2
3
  import type {Key, KeyedValue, PlainObject} from '~/models';
3
4
 
@@ -10,18 +11,18 @@ export function toRecord<Item>(array: Item[]): Record<number, Item>;
10
11
  * Create a record from an array of items using a specific key
11
12
  */
12
13
  export function toRecord<Item extends PlainObject, ItemKey extends keyof Item>(
13
- array: Item[],
14
- key: ItemKey,
15
- ): Record<KeyedValue<Item, ItemKey>, Item>;
14
+ array: Item[],
15
+ key: ItemKey,
16
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Item>>;
16
17
 
17
18
  /**
18
19
  * Create a record from an array of items using a specific key, and grouping them into arrays
19
20
  */
20
21
  export function toRecord<Item extends PlainObject, ItemKey extends keyof Item>(
21
- array: Item[],
22
- key: ItemKey,
23
- arrays: true,
24
- ): Record<KeyedValue<Item, ItemKey>, Item[]>;
22
+ array: Item[],
23
+ key: ItemKey,
24
+ arrays: true,
25
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Item[]>>;
25
26
 
26
27
  /**
27
28
  * Create a record from an array of items using a specific key
@@ -47,82 +48,82 @@ export function toRecord<
47
48
  * Create a record from an array of items using a specific key and value
48
49
  */
49
50
  export function toRecord<
50
- Item extends PlainObject,
51
- ItemKey extends keyof Item,
52
- ItemValue extends keyof Item,
53
- >(
54
- array: Item[],
55
- key: ItemKey,
56
- value: ItemValue,
57
- ): Record<KeyedValue<Item, ItemKey>, KeyedValue<Item, ItemValue>>;
51
+ Item extends PlainObject,
52
+ ItemKey extends keyof Item,
53
+ ItemValue extends keyof Item,
54
+ >(
55
+ array: Item[],
56
+ key: ItemKey,
57
+ value: ItemValue,
58
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Item[ItemValue]>>;
58
59
 
59
60
  /**
60
61
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
61
62
  */
62
63
  export function toRecord<
63
- Item extends PlainObject,
64
- ItemKey extends keyof Item,
65
- ItemValue extends keyof Item,
66
- >(
67
- array: Item[],
68
- key: ItemKey,
69
- value: ItemValue,
70
- arrays: true,
71
- ): Record<KeyedValue<Item, ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
64
+ Item extends PlainObject,
65
+ ItemKey extends keyof Item,
66
+ ItemValue extends keyof Item,
67
+ >(
68
+ array: Item[],
69
+ key: ItemKey,
70
+ value: ItemValue,
71
+ arrays: true,
72
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Array<Item[ItemValue]>>>;
72
73
 
73
74
  /**
74
75
  * Create a record from an array of items using a specific key and value
75
76
  */
76
77
  export function toRecord<
77
- Item extends PlainObject,
78
- ItemKey extends keyof Item,
79
- ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
80
- >(
81
- array: Item[],
82
- key: ItemKey,
83
- value: ItemValue,
84
- ): Record<KeyedValue<Item, ItemKey>, ReturnType<ItemValue>>;
78
+ Item extends PlainObject,
79
+ ItemKey extends keyof Item,
80
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
81
+ >(
82
+ array: Item[],
83
+ key: ItemKey,
84
+ value: ItemValue,
85
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, ReturnType<ItemValue>>>;
85
86
 
86
87
  /**
87
88
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
88
89
  */
89
90
  export function toRecord<
90
- Item extends PlainObject,
91
- ItemKey extends keyof Item,
92
- ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
93
- >(
94
- array: Item[],
95
- key: ItemKey,
96
- value: ItemValue,
97
- arrays: true,
98
- ): Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ItemValue>>>;
91
+ Item extends PlainObject,
92
+ ItemKey extends keyof Item,
93
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
94
+ >(
95
+ array: Item[],
96
+ key: ItemKey,
97
+ value: ItemValue,
98
+ arrays: true,
99
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ItemValue>>>>;
99
100
 
100
101
  /**
101
102
  * Create a record from an array of items using a specific key and value
102
103
  */
103
104
  export function toRecord<
104
- Item extends PlainObject,
105
- ItemKey extends (item: Item, index: number, array: Item[]) => Key,
106
- ItemValue extends keyof Item,
107
- >(
108
- array: Item[],
109
- key: ItemKey,
110
- value: ItemValue,
111
- ): Record<ReturnType<ItemKey>, KeyedValue<Item, ItemValue>>;
105
+ Item extends PlainObject,
106
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
107
+ ItemValue extends keyof Item,
108
+ >(
109
+ array: Item[],
110
+ key: ItemKey,
111
+ value: ItemValue,
112
+ ): Record<ReturnType<ItemKey>, Item[ItemValue]>;
112
113
 
113
114
  /**
114
115
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
115
116
  */
116
117
  export function toRecord<
117
- Item extends PlainObject,
118
- ItemKey extends (item: Item, index: number, array: Item[]) => Key,
119
- ItemValue extends keyof Item,
120
- >(
121
- array: Item[],
122
- key: ItemKey,
123
- value: ItemValue,
124
- arrays: true,
125
- ): Record<ReturnType<ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
118
+ Item extends PlainObject,
119
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
120
+ ItemValue extends keyof Item,
121
+ >(
122
+ array: Item[],
123
+ key: ItemKey,
124
+ value: ItemValue,
125
+ arrays: true,
126
+ ): Record<ReturnType<ItemKey>, Array<Item[ItemValue]>>;
126
127
 
127
128
  /**
128
129
  * Create a record from an array of items using a specific key and value