@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.
- package/README.md +2 -2
- package/package.json +39 -78
- package/src/{js/array → array}/group-by.ts +10 -9
- package/src/{js/array → array}/to-map.ts +20 -20
- package/src/{js/array → array}/to-record.ts +59 -58
- package/types/array/group-by.d.cts +69 -9
- package/types/array/group-by.d.ts +10 -9
- package/types/array/index.d.cts +87 -27
- package/types/array/to-map.d.cts +10 -11
- package/types/array/to-map.d.ts +11 -11
- package/types/array/to-record.d.cts +68 -8
- package/types/array/to-record.d.ts +9 -8
- package/types/index.d.cts +41 -39
- package/dist/css/a11y.css +0 -13
- package/dist/css/flex.css +0 -150
- package/dist/css/reset.css +0 -316
- package/src/css/a11y.scss +0 -16
- package/src/css/flex.scss +0 -104
- package/src/css/reset.scss +0 -323
- /package/dist/{js/array → array}/chunk.cjs +0 -0
- /package/dist/{js/array → array}/chunk.js +0 -0
- /package/dist/{js/array → array}/compact.cjs +0 -0
- /package/dist/{js/array → array}/compact.js +0 -0
- /package/dist/{js/array → array}/count.cjs +0 -0
- /package/dist/{js/array → array}/count.js +0 -0
- /package/dist/{js/array → array}/exists.cjs +0 -0
- /package/dist/{js/array → array}/exists.js +0 -0
- /package/dist/{js/array → array}/filter.cjs +0 -0
- /package/dist/{js/array → array}/filter.js +0 -0
- /package/dist/{js/array → array}/find.cjs +0 -0
- /package/dist/{js/array → array}/find.js +0 -0
- /package/dist/{js/array → array}/group-by.cjs +0 -0
- /package/dist/{js/array → array}/group-by.js +0 -0
- /package/dist/{js/array → array}/index-of.cjs +0 -0
- /package/dist/{js/array → array}/index-of.js +0 -0
- /package/dist/{js/array → array}/index.cjs +0 -0
- /package/dist/{js/array → array}/index.js +0 -0
- /package/dist/{js/array → array}/insert.cjs +0 -0
- /package/dist/{js/array → array}/insert.js +0 -0
- /package/dist/{js/array → array}/models.cjs +0 -0
- /package/dist/{js/array → array}/models.js +0 -0
- /package/dist/{js/array → array}/shuffle.cjs +0 -0
- /package/dist/{js/array → array}/shuffle.js +0 -0
- /package/dist/{js/array → array}/sort.cjs +0 -0
- /package/dist/{js/array → array}/sort.js +0 -0
- /package/dist/{js/array → array}/splice.cjs +0 -0
- /package/dist/{js/array → array}/splice.js +0 -0
- /package/dist/{js/array → array}/to-map.cjs +0 -0
- /package/dist/{js/array → array}/to-map.js +0 -0
- /package/dist/{js/array → array}/to-record.cjs +0 -0
- /package/dist/{js/array → array}/to-record.js +0 -0
- /package/dist/{js/array → array}/unique.cjs +0 -0
- /package/dist/{js/array → array}/unique.js +0 -0
- /package/dist/{js/colour → colour}/base.cjs +0 -0
- /package/dist/{js/colour → colour}/base.js +0 -0
- /package/dist/{js/colour → colour}/functions.cjs +0 -0
- /package/dist/{js/colour → colour}/functions.js +0 -0
- /package/dist/{js/colour → colour}/hex.cjs +0 -0
- /package/dist/{js/colour → colour}/hex.js +0 -0
- /package/dist/{js/colour → colour}/hsl.cjs +0 -0
- /package/dist/{js/colour → colour}/hsl.js +0 -0
- /package/dist/{js/colour → colour}/index.cjs +0 -0
- /package/dist/{js/colour → colour}/index.js +0 -0
- /package/dist/{js/colour → colour}/is.cjs +0 -0
- /package/dist/{js/colour → colour}/is.js +0 -0
- /package/dist/{js/colour → colour}/rgb.cjs +0 -0
- /package/dist/{js/colour → colour}/rgb.js +0 -0
- /package/dist/{js/emitter.cjs → emitter.cjs} +0 -0
- /package/dist/{js/emitter.js → emitter.js} +0 -0
- /package/dist/{js/function.cjs → function.cjs} +0 -0
- /package/dist/{js/function.js → function.js} +0 -0
- /package/dist/{js/index.cjs → index.cjs} +0 -0
- /package/dist/{js/index.js → index.js} +0 -0
- /package/dist/{js/internal → internal}/array/callbacks.cjs +0 -0
- /package/dist/{js/internal → internal}/array/callbacks.js +0 -0
- /package/dist/{js/internal → internal}/array/find.cjs +0 -0
- /package/dist/{js/internal → internal}/array/find.js +0 -0
- /package/dist/{js/internal → internal}/value/handle.cjs +0 -0
- /package/dist/{js/internal → internal}/value/handle.js +0 -0
- /package/dist/{js/is.cjs → is.cjs} +0 -0
- /package/dist/{js/is.js → is.js} +0 -0
- /package/dist/{js/logger.cjs → logger.cjs} +0 -0
- /package/dist/{js/logger.js → logger.js} +0 -0
- /package/dist/{js/math.cjs → math.cjs} +0 -0
- /package/dist/{js/math.js → math.js} +0 -0
- /package/dist/{js/models.cjs → models.cjs} +0 -0
- /package/dist/{js/models.js → models.js} +0 -0
- /package/dist/{js/number.cjs → number.cjs} +0 -0
- /package/dist/{js/number.js → number.js} +0 -0
- /package/dist/{js/query.cjs → query.cjs} +0 -0
- /package/dist/{js/query.js → query.js} +0 -0
- /package/dist/{js/queue.cjs → queue.cjs} +0 -0
- /package/dist/{js/queue.js → queue.js} +0 -0
- /package/dist/{js/random.cjs → random.cjs} +0 -0
- /package/dist/{js/random.js → random.js} +0 -0
- /package/dist/{js/sized.cjs → sized.cjs} +0 -0
- /package/dist/{js/sized.js → sized.js} +0 -0
- /package/dist/{js/string → string}/case.cjs +0 -0
- /package/dist/{js/string → string}/case.js +0 -0
- /package/dist/{js/string → string}/index.cjs +0 -0
- /package/dist/{js/string → string}/index.js +0 -0
- /package/dist/{js/string → string}/template.cjs +0 -0
- /package/dist/{js/string → string}/template.js +0 -0
- /package/dist/{js/touch.cjs → touch.cjs} +0 -0
- /package/dist/{js/touch.js → touch.js} +0 -0
- /package/dist/{js/value → value}/clone.cjs +0 -0
- /package/dist/{js/value → value}/clone.js +0 -0
- /package/dist/{js/value → value}/compare.cjs +0 -0
- /package/dist/{js/value → value}/compare.js +0 -0
- /package/dist/{js/value → value}/diff.cjs +0 -0
- /package/dist/{js/value → value}/diff.js +0 -0
- /package/dist/{js/value → value}/equal.cjs +0 -0
- /package/dist/{js/value → value}/equal.js +0 -0
- /package/dist/{js/value → value}/get.cjs +0 -0
- /package/dist/{js/value → value}/get.js +0 -0
- /package/dist/{js/value → value}/index.cjs +0 -0
- /package/dist/{js/value → value}/index.js +0 -0
- /package/dist/{js/value → value}/merge.cjs +0 -0
- /package/dist/{js/value → value}/merge.js +0 -0
- /package/dist/{js/value → value}/set.cjs +0 -0
- /package/dist/{js/value → value}/set.js +0 -0
- /package/dist/{js/value → value}/smush.cjs +0 -0
- /package/dist/{js/value → value}/smush.js +0 -0
- /package/dist/{js/value → value}/unsmush.cjs +0 -0
- /package/dist/{js/value → value}/unsmush.js +0 -0
- /package/src/{js/array → array}/chunk.ts +0 -0
- /package/src/{js/array → array}/compact.ts +0 -0
- /package/src/{js/array → array}/count.ts +0 -0
- /package/src/{js/array → array}/exists.ts +0 -0
- /package/src/{js/array → array}/filter.ts +0 -0
- /package/src/{js/array → array}/find.ts +0 -0
- /package/src/{js/array → array}/index-of.ts +0 -0
- /package/src/{js/array → array}/index.ts +0 -0
- /package/src/{js/array → array}/insert.ts +0 -0
- /package/src/{js/array → array}/models.ts +0 -0
- /package/src/{js/array → array}/shuffle.ts +0 -0
- /package/src/{js/array → array}/sort.ts +0 -0
- /package/src/{js/array → array}/splice.ts +0 -0
- /package/src/{js/array → array}/unique.ts +0 -0
- /package/src/{js/colour → colour}/base.ts +0 -0
- /package/src/{js/colour → colour}/functions.ts +0 -0
- /package/src/{js/colour → colour}/hex.ts +0 -0
- /package/src/{js/colour → colour}/hsl.ts +0 -0
- /package/src/{js/colour → colour}/index.ts +0 -0
- /package/src/{js/colour → colour}/is.ts +0 -0
- /package/src/{js/colour → colour}/rgb.ts +0 -0
- /package/src/{js/emitter.ts → emitter.ts} +0 -0
- /package/src/{js/function.ts → function.ts} +0 -0
- /package/src/{js/index.ts → index.ts} +0 -0
- /package/src/{js/internal → internal}/array/callbacks.ts +0 -0
- /package/src/{js/internal → internal}/array/find.ts +0 -0
- /package/src/{js/internal → internal}/value/handle.ts +0 -0
- /package/src/{js/is.ts → is.ts} +0 -0
- /package/src/{js/logger.ts → logger.ts} +0 -0
- /package/src/{js/math.ts → math.ts} +0 -0
- /package/src/{js/models.ts → models.ts} +0 -0
- /package/src/{js/number.ts → number.ts} +0 -0
- /package/src/{js/query.ts → query.ts} +0 -0
- /package/src/{js/queue.ts → queue.ts} +0 -0
- /package/src/{js/random.ts → random.ts} +0 -0
- /package/src/{js/sized.ts → sized.ts} +0 -0
- /package/src/{js/string → string}/case.ts +0 -0
- /package/src/{js/string → string}/index.ts +0 -0
- /package/src/{js/string → string}/template.ts +0 -0
- /package/src/{js/touch.ts → touch.ts} +0 -0
- /package/src/{js/value → value}/clone.ts +0 -0
- /package/src/{js/value → value}/compare.ts +0 -0
- /package/src/{js/value → value}/diff.ts +0 -0
- /package/src/{js/value → value}/equal.ts +0 -0
- /package/src/{js/value → value}/get.ts +0 -0
- /package/src/{js/value → value}/index.ts +0 -0
- /package/src/{js/value → value}/merge.ts +0 -0
- /package/src/{js/value → value}/set.ts +0 -0
- /package/src/{js/value → value}/smush.ts +0 -0
- /package/src/{js/value → value}/unsmush.ts +0 -0
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Atoms
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@oscarpalmer/atoms)
|
|
3
|
+
[](https://www.npmjs.com/package/@oscarpalmer/atoms) [](https://github.com/oscarpalmer/atoms/actions/workflows/test.yml)
|
|
4
4
|
|
|
5
|
-
|
|
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": "
|
|
9
|
+
"description": "Atomic utilities for making your JavaScript better.",
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@biomejs/biome": "^1.9",
|
|
12
|
-
"@types/node": "^22.
|
|
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/
|
|
26
|
+
"default": "./dist/index.js"
|
|
29
27
|
},
|
|
30
28
|
"require": {
|
|
31
29
|
"types": "./types/index.d.cts",
|
|
32
|
-
"default": "./dist/
|
|
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/
|
|
36
|
+
"default": "./dist/array/index.js"
|
|
40
37
|
},
|
|
41
38
|
"require": {
|
|
42
39
|
"types": "./types/array/index.d.cts",
|
|
43
|
-
"default": "./dist/
|
|
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/
|
|
46
|
+
"default": "./dist/colour/index.js"
|
|
51
47
|
},
|
|
52
48
|
"require": {
|
|
53
49
|
"types": "./types/colour/index.d.cts",
|
|
54
|
-
"default": "./dist/
|
|
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/
|
|
56
|
+
"default": "./dist/emitter.js"
|
|
74
57
|
},
|
|
75
58
|
"require": {
|
|
76
59
|
"types": "./types/emitter.d.cts",
|
|
77
|
-
"default": "./dist/
|
|
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/
|
|
66
|
+
"default": "./dist/function.js"
|
|
85
67
|
},
|
|
86
68
|
"require": {
|
|
87
69
|
"types": "./types/function.d.cts",
|
|
88
|
-
"default": "./dist/
|
|
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/
|
|
76
|
+
"default": "./dist/is.js"
|
|
96
77
|
},
|
|
97
78
|
"require": {
|
|
98
79
|
"types": "./types/is.d.cts",
|
|
99
|
-
"default": "./dist/
|
|
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/
|
|
86
|
+
"default": "./dist/logger.js"
|
|
107
87
|
},
|
|
108
88
|
"require": {
|
|
109
89
|
"types": "./types/logger.d.cts",
|
|
110
|
-
"default": "./dist/
|
|
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/
|
|
96
|
+
"default": "./dist/math.js"
|
|
118
97
|
},
|
|
119
98
|
"require": {
|
|
120
99
|
"types": "./types/math.d.cts",
|
|
121
|
-
"default": "./dist/
|
|
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/
|
|
114
|
+
"default": "./dist/number.js"
|
|
138
115
|
},
|
|
139
116
|
"require": {
|
|
140
117
|
"types": "./types/number.d.cts",
|
|
141
|
-
"default": "./dist/
|
|
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/
|
|
124
|
+
"default": "./dist/query.js"
|
|
149
125
|
},
|
|
150
126
|
"require": {
|
|
151
127
|
"types": "./types/query.d.cts",
|
|
152
|
-
"default": "./dist/
|
|
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/
|
|
134
|
+
"default": "./dist/queue.js"
|
|
160
135
|
},
|
|
161
136
|
"require": {
|
|
162
137
|
"types": "./types/queue.d.cts",
|
|
163
|
-
"default": "./dist/
|
|
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/
|
|
144
|
+
"default": "./dist/random.js"
|
|
171
145
|
},
|
|
172
146
|
"require": {
|
|
173
147
|
"types": "./types/random.d.cts",
|
|
174
|
-
"default": "./dist/
|
|
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/
|
|
154
|
+
"default": "./dist/string/index.js"
|
|
182
155
|
},
|
|
183
156
|
"require": {
|
|
184
157
|
"types": "./types/string/index.d.cts",
|
|
185
|
-
"default": "./dist/
|
|
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/
|
|
164
|
+
"default": "./dist/touch.js"
|
|
193
165
|
},
|
|
194
166
|
"require": {
|
|
195
167
|
"types": "./types/touch.d.cts",
|
|
196
|
-
"default": "./dist/
|
|
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/
|
|
174
|
+
"default": "./dist/value/index.js"
|
|
204
175
|
},
|
|
205
176
|
"require": {
|
|
206
177
|
"types": "./types/value/index.d.cts",
|
|
207
|
-
"default": "./dist/
|
|
178
|
+
"default": "./dist/value/index.cjs"
|
|
208
179
|
}
|
|
209
180
|
}
|
|
210
181
|
},
|
|
211
|
-
"files": [
|
|
212
|
-
|
|
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/
|
|
222
|
-
"module": "./dist/
|
|
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 &&
|
|
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
|
|
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.
|
|
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>,
|
|
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<
|
|
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>,
|
|
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<
|
|
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,
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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>,
|
|
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<
|
|
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
|
-
|
|
129
|
-
|
|
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:
|
|
133
|
-
value:
|
|
134
|
-
): Map<ReturnType<
|
|
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
|
-
|
|
142
|
-
|
|
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:
|
|
146
|
-
value:
|
|
145
|
+
key: ItemKey,
|
|
146
|
+
value: ItemValue,
|
|
147
147
|
arrays: true,
|
|
148
|
-
): Map<ReturnType<
|
|
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<
|
|
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
|
-
|
|
14
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
>(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
): Record<KeyedValue<Item, ItemKey>,
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
>(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
): Record<KeyedValue<Item, ItemKey>, Array<
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
>(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
>(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
>(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
): Record<ReturnType<ItemKey>,
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
>(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
): Record<ReturnType<ItemKey>, Array<
|
|
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
|