es-toolkit 1.9.0 → 1.10.0-dev.204
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/CHANGELOG.md +22 -1
- package/README.md +1 -1
- package/dist/array/chunk.mjs +1 -1
- package/dist/array/compact.mjs +1 -1
- package/dist/array/countBy.mjs +1 -1
- package/dist/array/difference.mjs +1 -1
- package/dist/array/differenceBy.mjs +1 -1
- package/dist/array/differenceWith.mjs +1 -1
- package/dist/array/drop.mjs +1 -1
- package/dist/array/dropRight.mjs +1 -1
- package/dist/array/dropRightWhile.mjs +1 -1
- package/dist/array/dropWhile.mjs +1 -1
- package/dist/array/fill.mjs +1 -1
- package/dist/array/flatten.mjs +1 -1
- package/dist/array/flattenDeep.d.mts +25 -0
- package/dist/array/flattenDeep.d.ts +25 -0
- package/dist/array/flattenDeep.js +52 -0
- package/dist/array/flattenDeep.js.map +1 -0
- package/dist/array/flattenDeep.mjs +9 -0
- package/dist/array/forEachRight.mjs +1 -1
- package/dist/array/groupBy.mjs +1 -1
- package/dist/array/head.mjs +1 -1
- package/dist/array/index.d.mts +4 -0
- package/dist/array/index.d.ts +4 -0
- package/dist/array/index.js +38 -0
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +45 -29
- package/dist/array/initial.d.mts +26 -0
- package/dist/array/initial.d.ts +26 -0
- package/dist/array/initial.js +36 -0
- package/dist/array/initial.js.map +1 -0
- package/dist/array/initial.mjs +8 -0
- package/dist/array/intersection.mjs +1 -1
- package/dist/array/intersectionBy.mjs +1 -1
- package/dist/array/intersectionWith.mjs +1 -1
- package/dist/array/keyBy.mjs +1 -1
- package/dist/array/last.d.mts +25 -0
- package/dist/array/last.d.ts +25 -0
- package/dist/array/last.js +33 -0
- package/dist/array/last.js.map +1 -0
- package/dist/array/last.mjs +8 -0
- package/dist/array/maxBy.mjs +1 -1
- package/dist/array/minBy.mjs +1 -1
- package/dist/array/orderBy.mjs +1 -1
- package/dist/array/partition.mjs +1 -1
- package/dist/array/sample.mjs +1 -1
- package/dist/array/sampleSize.mjs +1 -1
- package/dist/array/shuffle.mjs +1 -1
- package/dist/array/tail.mjs +1 -1
- package/dist/array/take.mjs +1 -1
- package/dist/array/takeRight.mjs +1 -1
- package/dist/array/takeRightWhile.mjs +1 -1
- package/dist/array/takeWhile.mjs +1 -1
- package/dist/array/toFilled.d.mts +33 -0
- package/dist/array/toFilled.d.ts +33 -0
- package/dist/array/toFilled.js +40 -0
- package/dist/array/toFilled.js.map +1 -0
- package/dist/array/toFilled.mjs +8 -0
- package/dist/array/union.mjs +1 -1
- package/dist/array/unionBy.mjs +1 -1
- package/dist/array/unionWith.mjs +1 -1
- package/dist/array/uniq.mjs +1 -1
- package/dist/array/uniqBy.mjs +1 -1
- package/dist/array/uniqWith.mjs +1 -1
- package/dist/array/unzip.mjs +1 -1
- package/dist/array/unzipWith.mjs +1 -1
- package/dist/array/without.mjs +1 -1
- package/dist/array/xor.mjs +1 -1
- package/dist/array/xorBy.mjs +1 -1
- package/dist/array/xorWith.mjs +1 -1
- package/dist/array/zip.mjs +1 -1
- package/dist/array/zipObject.mjs +1 -1
- package/dist/array/zipWith.mjs +1 -1
- package/dist/chunk-236H5JZJ.mjs +1 -0
- package/dist/chunk-2HIMLZE3.mjs +46 -0
- package/dist/chunk-2HIMLZE3.mjs.map +1 -0
- package/dist/chunk-2MRZANXZ.mjs +1 -0
- package/dist/chunk-2MRZANXZ.mjs.map +1 -0
- package/dist/chunk-2SLTL4KL.mjs +13 -0
- package/dist/{chunk-NOFHNJ5C.mjs.map → chunk-2SLTL4KL.mjs.map} +1 -1
- package/dist/{chunk-QZITBKWX.mjs → chunk-4E4D3BMI.mjs} +2 -2
- package/dist/chunk-5IKVJGHO.mjs +14 -0
- package/dist/chunk-5IKVJGHO.mjs.map +1 -0
- package/dist/chunk-ASJF5D6C.mjs +1 -0
- package/dist/chunk-ASJF5D6C.mjs.map +1 -0
- package/dist/chunk-BOOQBJN2.mjs +9 -0
- package/dist/chunk-BOOQBJN2.mjs.map +1 -0
- package/dist/chunk-EYYZQFOP.mjs +14 -0
- package/dist/chunk-EYYZQFOP.mjs.map +1 -0
- package/dist/chunk-F3WCQQET.mjs +14 -0
- package/dist/chunk-F3WCQQET.mjs.map +1 -0
- package/dist/{chunk-LT6E4Y4Z.mjs → chunk-GDC64SYJ.mjs} +2 -2
- package/dist/{chunk-SDIMTYZW.mjs → chunk-IZAD2S7R.mjs} +2 -2
- package/dist/chunk-JYSV56US.mjs +41 -0
- package/dist/chunk-JYSV56US.mjs.map +1 -0
- package/dist/chunk-KPBQ7OUY.mjs +9 -0
- package/dist/chunk-KPBQ7OUY.mjs.map +1 -0
- package/dist/chunk-ML727RRJ.mjs +13 -0
- package/dist/chunk-ML727RRJ.mjs.map +1 -0
- package/dist/chunk-NKLIE2OI.mjs +1 -0
- package/dist/chunk-NKLIE2OI.mjs.map +1 -0
- package/dist/chunk-OP4OAKQJ.mjs +16 -0
- package/dist/chunk-OP4OAKQJ.mjs.map +1 -0
- package/dist/chunk-OSOLEQLZ.mjs +1 -0
- package/dist/chunk-OSOLEQLZ.mjs.map +1 -0
- package/dist/chunk-QKYYOLJ6.mjs +1 -0
- package/dist/chunk-QKYYOLJ6.mjs.map +1 -0
- package/dist/chunk-U4JGKZ56.mjs +41 -0
- package/dist/chunk-U4JGKZ56.mjs.map +1 -0
- package/dist/chunk-U56ZOM7L.mjs +9 -0
- package/dist/chunk-U56ZOM7L.mjs.map +1 -0
- package/dist/chunk-WMM7TZLG.mjs +9 -0
- package/dist/{chunk-OHQAR5AU.mjs.map → chunk-WMM7TZLG.mjs.map} +1 -1
- package/dist/chunk-WVQ7YVRK.mjs +11 -0
- package/dist/chunk-WVQ7YVRK.mjs.map +1 -0
- package/dist/chunk-XGCYC4YA.mjs +5516 -0
- package/dist/chunk-XGCYC4YA.mjs.map +1 -0
- package/dist/chunk-XPSOKBRZ.mjs +12 -0
- package/dist/chunk-XPSOKBRZ.mjs.map +1 -0
- package/dist/compat/index.d.mts +108 -0
- package/dist/compat/index.d.ts +108 -0
- package/dist/compat/index.js +6578 -0
- package/dist/compat/index.js.map +1 -0
- package/dist/compat/index.mjs +351 -0
- package/dist/compat/index.mjs.map +1 -0
- package/dist/error/AbortError.mjs +1 -1
- package/dist/error/index.mjs +1 -1
- package/dist/function/debounce.mjs +1 -1
- package/dist/function/index.d.mts +1 -0
- package/dist/function/index.d.ts +1 -0
- package/dist/function/index.js +7 -0
- package/dist/function/index.js.map +1 -1
- package/dist/function/index.mjs +8 -4
- package/dist/function/negate.d.mts +10 -0
- package/dist/function/negate.d.ts +10 -0
- package/dist/function/negate.js +33 -0
- package/dist/function/negate.js.map +1 -0
- package/dist/function/negate.mjs +8 -0
- package/dist/function/negate.mjs.map +1 -0
- package/dist/function/noop.mjs +1 -1
- package/dist/function/once.mjs +1 -1
- package/dist/function/throttle.mjs +1 -1
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +5681 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +101 -50
- package/dist/math/clamp.mjs +1 -1
- package/dist/math/inRange.mjs +1 -1
- package/dist/math/index.js +2 -2
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +9 -9
- package/dist/math/mean.js +2 -2
- package/dist/math/mean.js.map +1 -1
- package/dist/math/mean.mjs +3 -3
- package/dist/math/meanBy.js +2 -2
- package/dist/math/meanBy.js.map +1 -1
- package/dist/math/meanBy.mjs +4 -4
- package/dist/math/random.mjs +1 -1
- package/dist/math/randomInt.mjs +1 -1
- package/dist/math/range.mjs +1 -1
- package/dist/math/round.mjs +1 -1
- package/dist/math/sum.js +2 -2
- package/dist/math/sum.js.map +1 -1
- package/dist/math/sum.mjs +2 -2
- package/dist/object/clone.d.mts +31 -0
- package/dist/object/clone.d.ts +31 -0
- package/dist/object/clone.js +65 -0
- package/dist/object/clone.js.map +1 -0
- package/dist/object/clone.mjs +8 -0
- package/dist/object/clone.mjs.map +1 -0
- package/dist/object/index.d.mts +1 -0
- package/dist/object/index.d.ts +1 -0
- package/dist/object/index.js +39 -0
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +7 -3
- package/dist/object/invert.mjs +1 -1
- package/dist/object/omit.mjs +2 -2
- package/dist/object/omitBy.mjs +1 -1
- package/dist/object/pick.mjs +1 -1
- package/dist/object/pickBy.mjs +1 -1
- package/dist/predicate/index.d.mts +1 -0
- package/dist/predicate/index.d.ts +1 -0
- package/dist/predicate/index.js +46 -1
- package/dist/predicate/index.js.map +1 -1
- package/dist/predicate/index.mjs +9 -3
- package/dist/predicate/isEqual.d.mts +17 -0
- package/dist/predicate/isEqual.d.ts +17 -0
- package/dist/predicate/isEqual.js +73 -0
- package/dist/predicate/isEqual.js.map +1 -0
- package/dist/predicate/isEqual.mjs +10 -0
- package/dist/predicate/isEqual.mjs.map +1 -0
- package/dist/predicate/isNil.js +1 -1
- package/dist/predicate/isNil.js.map +1 -1
- package/dist/predicate/isNil.mjs +2 -2
- package/dist/predicate/isNotNil.mjs +1 -1
- package/dist/predicate/isNull.mjs +1 -1
- package/dist/predicate/isUndefined.mjs +1 -1
- package/dist/promise/delay.mjs +1 -1
- package/dist/promise/index.mjs +1 -1
- package/dist/string/camelCase.d.mts +17 -0
- package/dist/string/camelCase.d.ts +17 -0
- package/dist/string/camelCase.js +5554 -0
- package/dist/string/camelCase.js.map +1 -0
- package/dist/string/camelCase.mjs +9 -0
- package/dist/string/camelCase.mjs.map +1 -0
- package/dist/string/capitalize.d.mts +14 -0
- package/dist/string/capitalize.d.ts +14 -0
- package/dist/string/capitalize.js +33 -0
- package/dist/string/capitalize.js.map +1 -0
- package/dist/string/capitalize.mjs +8 -0
- package/dist/string/capitalize.mjs.map +1 -0
- package/dist/string/index.d.mts +5 -0
- package/dist/string/index.d.ts +5 -0
- package/dist/string/index.js +5587 -0
- package/dist/string/index.js.map +1 -0
- package/dist/string/index.mjs +26 -0
- package/dist/string/index.mjs.map +1 -0
- package/dist/string/kebabCase.d.mts +17 -0
- package/dist/string/kebabCase.d.ts +17 -0
- package/dist/string/kebabCase.js +43 -0
- package/dist/string/kebabCase.js.map +1 -0
- package/dist/string/kebabCase.mjs +9 -0
- package/dist/string/kebabCase.mjs.map +1 -0
- package/dist/string/lowerCase.d.mts +17 -0
- package/dist/string/lowerCase.d.ts +17 -0
- package/dist/string/lowerCase.js +43 -0
- package/dist/string/lowerCase.js.map +1 -0
- package/dist/string/lowerCase.mjs +9 -0
- package/dist/string/lowerCase.mjs.map +1 -0
- package/dist/string/snakeCase.d.mts +17 -0
- package/dist/string/snakeCase.d.ts +17 -0
- package/dist/string/snakeCase.js +43 -0
- package/dist/string/snakeCase.js.map +1 -0
- package/dist/string/snakeCase.mjs +9 -0
- package/dist/string/snakeCase.mjs.map +1 -0
- package/package.json +21 -1
- package/string.d.ts +1 -0
- package/dist/chunk-2MM5EJJX.mjs +0 -21
- package/dist/chunk-LOY6PATI.mjs +0 -1
- package/dist/chunk-MAJSPFA6.mjs +0 -1
- package/dist/chunk-N6EM6ETS.mjs +0 -1
- package/dist/chunk-NOFHNJ5C.mjs +0 -13
- package/dist/chunk-OHQAR5AU.mjs +0 -9
- package/dist/chunk-PMHULJNL.mjs +0 -1
- /package/dist/{chunk-2MM5EJJX.mjs.map → array/flattenDeep.mjs.map} +0 -0
- /package/dist/{chunk-LOY6PATI.mjs.map → array/initial.mjs.map} +0 -0
- /package/dist/{chunk-MAJSPFA6.mjs.map → array/last.mjs.map} +0 -0
- /package/dist/{chunk-N6EM6ETS.mjs.map → array/toFilled.mjs.map} +0 -0
- /package/dist/{chunk-PMHULJNL.mjs.map → chunk-236H5JZJ.mjs.map} +0 -0
- /package/dist/{chunk-QZITBKWX.mjs.map → chunk-4E4D3BMI.mjs.map} +0 -0
- /package/dist/{chunk-LT6E4Y4Z.mjs.map → chunk-GDC64SYJ.mjs.map} +0 -0
- /package/dist/{chunk-SDIMTYZW.mjs.map → chunk-IZAD2S7R.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,32 @@
|
|
|
1
|
+
import "./chunk-NKLIE2OI.mjs";
|
|
2
|
+
import "./chunk-QKYYOLJ6.mjs";
|
|
3
|
+
import {
|
|
4
|
+
kebabCase
|
|
5
|
+
} from "./chunk-EYYZQFOP.mjs";
|
|
6
|
+
import {
|
|
7
|
+
lowerCase
|
|
8
|
+
} from "./chunk-5IKVJGHO.mjs";
|
|
9
|
+
import {
|
|
10
|
+
snakeCase
|
|
11
|
+
} from "./chunk-F3WCQQET.mjs";
|
|
1
12
|
import "./chunk-ARZ5BDR6.mjs";
|
|
2
13
|
import {
|
|
3
14
|
delay
|
|
4
15
|
} from "./chunk-O64NE2P4.mjs";
|
|
5
|
-
import
|
|
16
|
+
import {
|
|
17
|
+
camelCase
|
|
18
|
+
} from "./chunk-XGCYC4YA.mjs";
|
|
19
|
+
import "./chunk-WVQ7YVRK.mjs";
|
|
20
|
+
import {
|
|
21
|
+
capitalize
|
|
22
|
+
} from "./chunk-U56ZOM7L.mjs";
|
|
23
|
+
import "./chunk-OSOLEQLZ.mjs";
|
|
6
24
|
import {
|
|
7
25
|
invert
|
|
8
26
|
} from "./chunk-74WWMNZS.mjs";
|
|
9
27
|
import {
|
|
10
28
|
omit
|
|
11
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-4E4D3BMI.mjs";
|
|
12
30
|
import {
|
|
13
31
|
omitBy
|
|
14
32
|
} from "./chunk-BCTYOXT7.mjs";
|
|
@@ -18,10 +36,10 @@ import {
|
|
|
18
36
|
import {
|
|
19
37
|
pickBy
|
|
20
38
|
} from "./chunk-6CLH5YZ2.mjs";
|
|
21
|
-
import "./chunk-
|
|
39
|
+
import "./chunk-ASJF5D6C.mjs";
|
|
22
40
|
import {
|
|
23
41
|
isNil
|
|
24
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-WMM7TZLG.mjs";
|
|
25
43
|
import {
|
|
26
44
|
isNotNil
|
|
27
45
|
} from "./chunk-BMRTZMRE.mjs";
|
|
@@ -31,29 +49,51 @@ import {
|
|
|
31
49
|
import {
|
|
32
50
|
isUndefined
|
|
33
51
|
} from "./chunk-VH2PV426.mjs";
|
|
34
|
-
import "./chunk-TLVQSNOE.mjs";
|
|
35
52
|
import {
|
|
36
|
-
|
|
37
|
-
} from "./chunk-
|
|
53
|
+
isEqual
|
|
54
|
+
} from "./chunk-JYSV56US.mjs";
|
|
55
|
+
import {
|
|
56
|
+
clone
|
|
57
|
+
} from "./chunk-U4JGKZ56.mjs";
|
|
58
|
+
import "./chunk-236H5JZJ.mjs";
|
|
59
|
+
import {
|
|
60
|
+
negate
|
|
61
|
+
} from "./chunk-BOOQBJN2.mjs";
|
|
62
|
+
import {
|
|
63
|
+
noop
|
|
64
|
+
} from "./chunk-LKXCOLNY.mjs";
|
|
65
|
+
import {
|
|
66
|
+
once
|
|
67
|
+
} from "./chunk-CMBC4MXG.mjs";
|
|
68
|
+
import {
|
|
69
|
+
throttle
|
|
70
|
+
} from "./chunk-QOJGMVVR.mjs";
|
|
71
|
+
import "./chunk-TLVQSNOE.mjs";
|
|
38
72
|
import {
|
|
39
73
|
meanBy
|
|
40
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-IZAD2S7R.mjs";
|
|
41
75
|
import {
|
|
42
76
|
mean
|
|
43
|
-
} from "./chunk-
|
|
44
|
-
import {
|
|
45
|
-
sum
|
|
46
|
-
} from "./chunk-NOFHNJ5C.mjs";
|
|
77
|
+
} from "./chunk-GDC64SYJ.mjs";
|
|
47
78
|
import {
|
|
48
79
|
range
|
|
49
80
|
} from "./chunk-DPH2KE6O.mjs";
|
|
50
81
|
import {
|
|
51
82
|
round
|
|
52
83
|
} from "./chunk-5PMKOZ2F.mjs";
|
|
84
|
+
import {
|
|
85
|
+
sum
|
|
86
|
+
} from "./chunk-2SLTL4KL.mjs";
|
|
53
87
|
import {
|
|
54
88
|
clamp
|
|
55
89
|
} from "./chunk-MLCL773E.mjs";
|
|
56
|
-
import
|
|
90
|
+
import {
|
|
91
|
+
inRange
|
|
92
|
+
} from "./chunk-BH6HLGBA.mjs";
|
|
93
|
+
import {
|
|
94
|
+
debounce
|
|
95
|
+
} from "./chunk-3IP4JVLL.mjs";
|
|
96
|
+
import "./chunk-2MRZANXZ.mjs";
|
|
57
97
|
import {
|
|
58
98
|
without
|
|
59
99
|
} from "./chunk-PYEYV7BY.mjs";
|
|
@@ -99,9 +139,6 @@ import {
|
|
|
99
139
|
import {
|
|
100
140
|
unzipWith
|
|
101
141
|
} from "./chunk-IFNXROZR.mjs";
|
|
102
|
-
import {
|
|
103
|
-
sample
|
|
104
|
-
} from "./chunk-2KNLZB7V.mjs";
|
|
105
142
|
import {
|
|
106
143
|
sampleSize
|
|
107
144
|
} from "./chunk-EHSKB6DF.mjs";
|
|
@@ -130,17 +167,17 @@ import {
|
|
|
130
167
|
takeWhile
|
|
131
168
|
} from "./chunk-2IXFGSUA.mjs";
|
|
132
169
|
import {
|
|
133
|
-
|
|
134
|
-
} from "./chunk-
|
|
135
|
-
import {
|
|
136
|
-
intersectionBy
|
|
137
|
-
} from "./chunk-O6UXZR3U.mjs";
|
|
170
|
+
toFilled
|
|
171
|
+
} from "./chunk-OP4OAKQJ.mjs";
|
|
138
172
|
import {
|
|
139
173
|
intersectionWith
|
|
140
174
|
} from "./chunk-XI7KRD2C.mjs";
|
|
141
175
|
import {
|
|
142
176
|
keyBy
|
|
143
177
|
} from "./chunk-AJKZMN2V.mjs";
|
|
178
|
+
import {
|
|
179
|
+
last
|
|
180
|
+
} from "./chunk-KPBQ7OUY.mjs";
|
|
144
181
|
import {
|
|
145
182
|
maxBy
|
|
146
183
|
} from "./chunk-OOKNBU4V.mjs";
|
|
@@ -154,17 +191,11 @@ import {
|
|
|
154
191
|
partition
|
|
155
192
|
} from "./chunk-DN3NOZ3H.mjs";
|
|
156
193
|
import {
|
|
157
|
-
|
|
158
|
-
} from "./chunk-
|
|
159
|
-
import {
|
|
160
|
-
dropWhile
|
|
161
|
-
} from "./chunk-LJ2C6MVP.mjs";
|
|
162
|
-
import {
|
|
163
|
-
fill
|
|
164
|
-
} from "./chunk-C4WE4GLC.mjs";
|
|
194
|
+
sample
|
|
195
|
+
} from "./chunk-2KNLZB7V.mjs";
|
|
165
196
|
import {
|
|
166
|
-
|
|
167
|
-
} from "./chunk-
|
|
197
|
+
flattenDeep
|
|
198
|
+
} from "./chunk-ML727RRJ.mjs";
|
|
168
199
|
import {
|
|
169
200
|
forEachRight
|
|
170
201
|
} from "./chunk-IEA53J7P.mjs";
|
|
@@ -175,17 +206,14 @@ import {
|
|
|
175
206
|
head
|
|
176
207
|
} from "./chunk-HM2JT2RX.mjs";
|
|
177
208
|
import {
|
|
178
|
-
|
|
179
|
-
} from "./chunk-
|
|
180
|
-
import {
|
|
181
|
-
compact
|
|
182
|
-
} from "./chunk-DTJJIMKJ.mjs";
|
|
209
|
+
initial
|
|
210
|
+
} from "./chunk-XPSOKBRZ.mjs";
|
|
183
211
|
import {
|
|
184
|
-
|
|
185
|
-
} from "./chunk-
|
|
212
|
+
intersection
|
|
213
|
+
} from "./chunk-FVVSE2F2.mjs";
|
|
186
214
|
import {
|
|
187
|
-
|
|
188
|
-
} from "./chunk-
|
|
215
|
+
intersectionBy
|
|
216
|
+
} from "./chunk-O6UXZR3U.mjs";
|
|
189
217
|
import {
|
|
190
218
|
differenceBy
|
|
191
219
|
} from "./chunk-LVWX5B43.mjs";
|
|
@@ -198,28 +226,42 @@ import {
|
|
|
198
226
|
import {
|
|
199
227
|
dropRight
|
|
200
228
|
} from "./chunk-JEKUA56R.mjs";
|
|
201
|
-
import "./chunk-N6EM6ETS.mjs";
|
|
202
229
|
import {
|
|
203
|
-
|
|
204
|
-
} from "./chunk-
|
|
230
|
+
dropRightWhile
|
|
231
|
+
} from "./chunk-JE6JKZU3.mjs";
|
|
205
232
|
import {
|
|
206
|
-
|
|
207
|
-
} from "./chunk-
|
|
233
|
+
dropWhile
|
|
234
|
+
} from "./chunk-LJ2C6MVP.mjs";
|
|
208
235
|
import {
|
|
209
|
-
|
|
210
|
-
} from "./chunk-
|
|
236
|
+
fill
|
|
237
|
+
} from "./chunk-C4WE4GLC.mjs";
|
|
211
238
|
import {
|
|
212
|
-
|
|
213
|
-
} from "./chunk-
|
|
239
|
+
flatten
|
|
240
|
+
} from "./chunk-33MSBDC6.mjs";
|
|
214
241
|
import "./chunk-FZEZH22H.mjs";
|
|
215
242
|
import {
|
|
216
243
|
AbortError
|
|
217
244
|
} from "./chunk-DXB7EZUQ.mjs";
|
|
218
|
-
import
|
|
245
|
+
import {
|
|
246
|
+
chunk
|
|
247
|
+
} from "./chunk-E6C5EZQA.mjs";
|
|
248
|
+
import {
|
|
249
|
+
compact
|
|
250
|
+
} from "./chunk-DTJJIMKJ.mjs";
|
|
251
|
+
import {
|
|
252
|
+
countBy
|
|
253
|
+
} from "./chunk-CRSKT4WW.mjs";
|
|
254
|
+
import {
|
|
255
|
+
difference
|
|
256
|
+
} from "./chunk-JPUKH67K.mjs";
|
|
257
|
+
import "./chunk-2HIMLZE3.mjs";
|
|
219
258
|
export {
|
|
220
259
|
AbortError,
|
|
260
|
+
camelCase,
|
|
261
|
+
capitalize,
|
|
221
262
|
chunk,
|
|
222
263
|
clamp,
|
|
264
|
+
clone,
|
|
223
265
|
compact,
|
|
224
266
|
countBy,
|
|
225
267
|
debounce,
|
|
@@ -233,23 +275,30 @@ export {
|
|
|
233
275
|
dropWhile,
|
|
234
276
|
fill,
|
|
235
277
|
flatten,
|
|
278
|
+
flattenDeep,
|
|
236
279
|
forEachRight,
|
|
237
280
|
groupBy,
|
|
238
281
|
head,
|
|
239
282
|
inRange,
|
|
283
|
+
initial,
|
|
240
284
|
intersection,
|
|
241
285
|
intersectionBy,
|
|
242
286
|
intersectionWith,
|
|
243
287
|
invert,
|
|
288
|
+
isEqual,
|
|
244
289
|
isNil,
|
|
245
290
|
isNotNil,
|
|
246
291
|
isNull,
|
|
247
292
|
isUndefined,
|
|
293
|
+
kebabCase,
|
|
248
294
|
keyBy,
|
|
295
|
+
last,
|
|
296
|
+
lowerCase,
|
|
249
297
|
maxBy,
|
|
250
298
|
mean,
|
|
251
299
|
meanBy,
|
|
252
300
|
minBy,
|
|
301
|
+
negate,
|
|
253
302
|
noop,
|
|
254
303
|
omit,
|
|
255
304
|
omitBy,
|
|
@@ -265,6 +314,7 @@ export {
|
|
|
265
314
|
sample,
|
|
266
315
|
sampleSize,
|
|
267
316
|
shuffle,
|
|
317
|
+
snakeCase,
|
|
268
318
|
sum,
|
|
269
319
|
tail,
|
|
270
320
|
take,
|
|
@@ -272,6 +322,7 @@ export {
|
|
|
272
322
|
takeRightWhile,
|
|
273
323
|
takeWhile,
|
|
274
324
|
throttle,
|
|
325
|
+
toFilled,
|
|
275
326
|
union,
|
|
276
327
|
unionBy,
|
|
277
328
|
unionWith,
|
package/dist/math/clamp.mjs
CHANGED
package/dist/math/inRange.mjs
CHANGED
package/dist/math/index.js
CHANGED
package/dist/math/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/math/index.ts","../../src/math/clamp.ts","../../src/math/inRange.ts","../../src/math/sum.ts","../../src/math/mean.ts","../../src/math/meanBy.ts","../../src/math/random.ts","../../src/math/randomInt.ts","../../src/math/round.ts","../../src/math/range.ts"],"sourcesContent":["export { clamp } from './clamp.ts';\nexport { inRange } from './inRange.ts';\nexport { mean } from './mean.ts';\nexport { meanBy } from './meanBy.ts';\nexport { random } from './random.ts';\nexport { randomInt } from './randomInt.ts';\nexport { round } from './round.ts';\nexport { sum } from './sum.ts';\nexport { range } from './range.ts';\n","/**\n * Clamps a number within the inclusive lower and upper bounds.\n *\n * This function takes a number and two bounds, and returns the number clamped within the specified bounds.\n * If only one bound is provided, it returns the minimum of the value and the bound.\n *\n * @param {number} value - The number to clamp.\n * @param {number} minimum - The minimum bound to clamp the number.\n * @param {number} maximum - The maximum bound to clamp the number.\n * @returns {number} The clamped number within the specified bounds.\n *\n * @example\n * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5\n * const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15\n * const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5\n * const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15\n */\nexport function clamp(value: number, maximum: number): number;\nexport function clamp(value: number, minimum: number, maximum: number): number;\nexport function clamp(value: number, bound1: number, bound2?: number): number {\n if (bound2 == null) {\n return Math.min(value, bound1);\n }\n\n return Math.min(Math.max(value, bound1), bound2);\n}\n","export function inRange(value: number, maximum: number): boolean;\nexport function inRange(value: number, minimum: number, maximum: number): boolean;\n/**\n * Checks if the value is within a specified range.\n *\n * @param {number} value The value to check.\n * @param {number} minimum The lower bound of the range (inclusive).\n * @param {number} maximum The upper bound of the range (exclusive).\n * @returns {boolean} `true` if the value is within the specified range, otherwise `false`.\n * @throws {Error} Throws an error if the `minimum` is greater or equal than the `maximum`.\n *\n * @example\n * const result1 = inRange(3, 5); // result1 will be true.\n * const result2 = inRange(1, 2, 5); // result2 will be false.\n * const result3 = inRange(1, 5, 2); // If the minimum is greater or equal than the maximum, an error is thrown.\n */\nexport function inRange(value: number, minimum: number, maximum?: number): boolean {\n if (maximum == null) {\n maximum = minimum;\n minimum = 0;\n }\n\n if (minimum >= maximum) {\n throw new Error('The maximum value must be greater than the minimum value.');\n }\n\n return minimum <= value && value < maximum;\n}\n","/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: readonly number[]): number {\n let result = 0;\n\n for (const num of nums) {\n result += num;\n }\n\n return result;\n}\n","import { sum } from './sum.ts';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @param {number[]} nums - An array of numbers to calculate the average.\n * @returns {number} The average of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = average(numbers);\n * // result will be 3\n */\nexport function mean(nums: readonly number[]): number {\n return sum(nums) / nums.length;\n}\n","import { mean } from './mean.ts';\n\n/**\n * Calculates the average of an array of numbers when applying\n * the `getValue` function to each element.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items An array to calculate the average.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {number} The average of all the numbers as determined by the `getValue` function.\n *\n * @example\n * meanBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 2\n * meanBy([], x => x.a); // Returns: NaN\n */\nexport function meanBy<T>(items: readonly T[], getValue: (element: T) => number): number {\n const nums = items.map(x => getValue(x));\n\n return mean(nums);\n}\n","/**\n * Generate a random number within the given range.\n *\n * If only one argument is provided, a number between `0` and the given number is returned.\n *\n * @param {number} minimum - The lower bound (inclusive).\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random number between minimum (inclusive) and maximum (exclusive). The number can be an integer or a decimal.\n * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.\n *\n * @example\n * const result1 = random(0, 5); // Returns a random number between 0 and 5.\n * const result2 = random(5, 0); // If the minimum is greater than the maximum, an error is thrown\n * const result3 = random(5, 5); // If the minimum is equal to the maximum, an error is thrown.\n */\nexport function random(maximum: number): number;\nexport function random(minimum: number, maximum: number): number;\nexport function random(minimum: number, maximum?: number): number {\n if (maximum == null) {\n maximum = minimum;\n minimum = 0;\n }\n\n if (minimum >= maximum) {\n throw new Error('Invalid input: The maximum value must be greater than the minimum value.');\n }\n\n return Math.random() * (maximum - minimum) + minimum;\n}\n","import { random } from './random.ts';\n\n/**\n * Generates a random integer between minimum (inclusive) and maximum (exclusive).\n *\n * If only one argument is provided, a number between `0` and the given number is returned.\n *\n * @param {number} minimum - The lower bound (inclusive).\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random integer between minimum (inclusive) and maximum (exclusive).\n * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.\n *\n * @example\n * const result = randomInt(0, 5); // result will be a random integer between 0 (inclusive) and 5 (exclusive)\n * const result2 = randomInt(5, 0); // This will throw an error\n */\nexport function randomInt(maximum: number): number;\nexport function randomInt(minimum: number, maximum: number): number;\nexport function randomInt(minimum: number, maximum?: number): number {\n return Math.floor(random(minimum, maximum!));\n}\n","/**\n * Rounds a number to a specified precision.\n *\n * This function takes a number and an optional precision value, and returns the number rounded\n * to the specified number of decimal places.\n *\n * @param {number} value - The number to round.\n * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.\n * @returns {number} The rounded number.\n * @throws {Error} Throws an error if `Precision` is not integer.\n *\n * @example\n * const result1 = round(1.2345); // result1 will be 1\n * const result2 = round(1.2345, 2); // result2 will be 1.23\n * const result3 = round(1.2345, 3); // result3 will be 1.235\n * const result4 = round(1.2345, 3.1); // This will throw an error\n */\nexport function round(value: number, precision = 0): number {\n if (!Number.isInteger(precision)) {\n throw new Error('Precision must be an integer.');\n }\n const multiplier = Math.pow(10, precision);\n return Math.round(value * multiplier) / multiplier;\n}\n","/**\n * Returns an array of numbers from `start` to `end`, incrementing by `step`.\n *\n * If `step` is not provided, it defaults to `1`.\n *\n * @param {number} start - The starting number of the range (inclusive).\n * @param {number} [end] - The end number of the range (exclusive).\n * @param {number} [step] - The step value for the range. (default: 1)\n * @returns {number[]} An array of numbers from `start` to `end` with the specified `step`.\n *\n * @example\n * // Returns [0, 1, 2, 3]\n * range(4);\n *\n * @example\n * // Returns [0, 5, 10, 15]\n * range(0, 20, 5);\n *\n * @example\n * // Returns [0, -1, -2, -3]\n * range(0, -4, -1);\n *\n * @example\n * // Throws an error: The step value must be a non-zero integer.\n * range(1, 4, 0);\n */\nexport function range(end: number): number[];\nexport function range(start: number, end: number): number[];\nexport function range(start: number, end: number, step: number): number[];\nexport function range(start: number, end?: number, step?: number): number[] {\n if (end == null) {\n end = start;\n start = 0;\n }\n\n if (step == null) {\n step = 1;\n }\n\n if (!Number.isInteger(step) || step === 0) {\n throw new Error(`The step value must be a non-zero integer.`);\n }\n\n const length = Math.max(Math.ceil((end - start) / step), 0);\n const result = new Array(length);\n\n for (let i = 0; i < length; i++) {\n result[i] = start + i * step;\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmBO,SAAS,MAAM,OAAe,QAAgB,QAAyB;AAC5E,MAAI,UAAU,MAAM;AAClB,WAAO,KAAK,IAAI,OAAO,MAAM;AAAA,EAC/B;AAEA,SAAO,KAAK,IAAI,KAAK,IAAI,OAAO,MAAM,GAAG,MAAM;AACjD;;;ACTO,SAAS,QAAQ,OAAe,SAAiB,SAA2B;AACjF,MAAI,WAAW,MAAM;AACnB,cAAU;AACV,cAAU;AAAA,EACZ;AAEA,MAAI,WAAW,SAAS;AACtB,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AAEA,SAAO,WAAW,SAAS,QAAQ;AACrC;;;ACdO,SAAS,IAAI,MAAiC;AACnD,MAAI,SAAS;AAEb,aAAW,OAAO,MAAM;AACtB,cAAU;AAAA,EACZ;AAEA,SAAO;AACT;;;ACNO,SAAS,KAAK,MAAiC;AACpD,SAAO,IAAI,IAAI,IAAI,KAAK;AAC1B;;;ACAO,SAAS,OAAU,OAAqB,UAA0C;AACvF,QAAM,OAAO,MAAM,IAAI,OAAK,SAAS,CAAC,CAAC;AAEvC,SAAO,KAAK,IAAI;AAClB;;;ACJO,SAAS,OAAO,SAAiB,SAA0B;AAChE,MAAI,WAAW,MAAM;AACnB,cAAU;AACV,cAAU;AAAA,EACZ;AAEA,MAAI,WAAW,SAAS;AACtB,UAAM,IAAI,MAAM,0EAA0E;AAAA,EAC5F;AAEA,SAAO,KAAK,OAAO,KAAK,UAAU,WAAW;AAC/C;;;ACVO,SAAS,UAAU,SAAiB,SAA0B;AACnE,SAAO,KAAK,MAAM,OAAO,SAAS,OAAQ,CAAC;AAC7C;;;ACHO,SAAS,MAAM,OAAe,YAAY,GAAW;AAC1D,MAAI,CAAC,OAAO,UAAU,SAAS,GAAG;AAChC,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AACA,QAAM,aAAa,KAAK,IAAI,IAAI,SAAS;AACzC,SAAO,KAAK,MAAM,QAAQ,UAAU,IAAI;AAC1C;;;ACMO,SAAS,MAAM,OAAe,KAAc,MAAyB;AAC1E,MAAI,OAAO,MAAM;AACf,UAAM;AACN,YAAQ;AAAA,EACV;AAEA,MAAI,QAAQ,MAAM;AAChB,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,OAAO,UAAU,IAAI,KAAK,SAAS,GAAG;AACzC,UAAM,IAAI,MAAM,4CAA4C;AAAA,EAC9D;AAEA,QAAM,SAAS,KAAK,IAAI,KAAK,MAAM,MAAM,SAAS,IAAI,GAAG,CAAC;AAC1D,QAAM,SAAS,IAAI,MAAM,MAAM;AAE/B,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK;AAC/B,WAAO,CAAC,IAAI,QAAQ,IAAI;AAAA,EAC1B;AAEA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/math/index.ts","../../src/math/clamp.ts","../../src/math/inRange.ts","../../src/math/sum.ts","../../src/math/mean.ts","../../src/math/meanBy.ts","../../src/math/random.ts","../../src/math/randomInt.ts","../../src/math/round.ts","../../src/math/range.ts"],"sourcesContent":["export { clamp } from './clamp.ts';\nexport { inRange } from './inRange.ts';\nexport { mean } from './mean.ts';\nexport { meanBy } from './meanBy.ts';\nexport { random } from './random.ts';\nexport { randomInt } from './randomInt.ts';\nexport { round } from './round.ts';\nexport { sum } from './sum.ts';\nexport { range } from './range.ts';\n","/**\n * Clamps a number within the inclusive lower and upper bounds.\n *\n * This function takes a number and two bounds, and returns the number clamped within the specified bounds.\n * If only one bound is provided, it returns the minimum of the value and the bound.\n *\n * @param {number} value - The number to clamp.\n * @param {number} minimum - The minimum bound to clamp the number.\n * @param {number} maximum - The maximum bound to clamp the number.\n * @returns {number} The clamped number within the specified bounds.\n *\n * @example\n * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5\n * const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15\n * const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5\n * const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15\n */\nexport function clamp(value: number, maximum: number): number;\nexport function clamp(value: number, minimum: number, maximum: number): number;\nexport function clamp(value: number, bound1: number, bound2?: number): number {\n if (bound2 == null) {\n return Math.min(value, bound1);\n }\n\n return Math.min(Math.max(value, bound1), bound2);\n}\n","export function inRange(value: number, maximum: number): boolean;\nexport function inRange(value: number, minimum: number, maximum: number): boolean;\n/**\n * Checks if the value is within a specified range.\n *\n * @param {number} value The value to check.\n * @param {number} minimum The lower bound of the range (inclusive).\n * @param {number} maximum The upper bound of the range (exclusive).\n * @returns {boolean} `true` if the value is within the specified range, otherwise `false`.\n * @throws {Error} Throws an error if the `minimum` is greater or equal than the `maximum`.\n *\n * @example\n * const result1 = inRange(3, 5); // result1 will be true.\n * const result2 = inRange(1, 2, 5); // result2 will be false.\n * const result3 = inRange(1, 5, 2); // If the minimum is greater or equal than the maximum, an error is thrown.\n */\nexport function inRange(value: number, minimum: number, maximum?: number): boolean {\n if (maximum == null) {\n maximum = minimum;\n minimum = 0;\n }\n\n if (minimum >= maximum) {\n throw new Error('The maximum value must be greater than the minimum value.');\n }\n\n return minimum <= value && value < maximum;\n}\n","/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: readonly number[]): number {\n let result = 0;\n\n for (let i = 0; i < nums.length; i++) {\n result += nums[i];\n }\n\n return result;\n}\n","import { sum } from './sum.ts';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @param {number[]} nums - An array of numbers to calculate the average.\n * @returns {number} The average of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = average(numbers);\n * // result will be 3\n */\nexport function mean(nums: readonly number[]): number {\n return sum(nums) / nums.length;\n}\n","import { mean } from './mean.ts';\n\n/**\n * Calculates the average of an array of numbers when applying\n * the `getValue` function to each element.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items An array to calculate the average.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {number} The average of all the numbers as determined by the `getValue` function.\n *\n * @example\n * meanBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 2\n * meanBy([], x => x.a); // Returns: NaN\n */\nexport function meanBy<T>(items: readonly T[], getValue: (element: T) => number): number {\n const nums = items.map(x => getValue(x));\n\n return mean(nums);\n}\n","/**\n * Generate a random number within the given range.\n *\n * If only one argument is provided, a number between `0` and the given number is returned.\n *\n * @param {number} minimum - The lower bound (inclusive).\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random number between minimum (inclusive) and maximum (exclusive). The number can be an integer or a decimal.\n * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.\n *\n * @example\n * const result1 = random(0, 5); // Returns a random number between 0 and 5.\n * const result2 = random(5, 0); // If the minimum is greater than the maximum, an error is thrown\n * const result3 = random(5, 5); // If the minimum is equal to the maximum, an error is thrown.\n */\nexport function random(maximum: number): number;\nexport function random(minimum: number, maximum: number): number;\nexport function random(minimum: number, maximum?: number): number {\n if (maximum == null) {\n maximum = minimum;\n minimum = 0;\n }\n\n if (minimum >= maximum) {\n throw new Error('Invalid input: The maximum value must be greater than the minimum value.');\n }\n\n return Math.random() * (maximum - minimum) + minimum;\n}\n","import { random } from './random.ts';\n\n/**\n * Generates a random integer between minimum (inclusive) and maximum (exclusive).\n *\n * If only one argument is provided, a number between `0` and the given number is returned.\n *\n * @param {number} minimum - The lower bound (inclusive).\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random integer between minimum (inclusive) and maximum (exclusive).\n * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.\n *\n * @example\n * const result = randomInt(0, 5); // result will be a random integer between 0 (inclusive) and 5 (exclusive)\n * const result2 = randomInt(5, 0); // This will throw an error\n */\nexport function randomInt(maximum: number): number;\nexport function randomInt(minimum: number, maximum: number): number;\nexport function randomInt(minimum: number, maximum?: number): number {\n return Math.floor(random(minimum, maximum!));\n}\n","/**\n * Rounds a number to a specified precision.\n *\n * This function takes a number and an optional precision value, and returns the number rounded\n * to the specified number of decimal places.\n *\n * @param {number} value - The number to round.\n * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.\n * @returns {number} The rounded number.\n * @throws {Error} Throws an error if `Precision` is not integer.\n *\n * @example\n * const result1 = round(1.2345); // result1 will be 1\n * const result2 = round(1.2345, 2); // result2 will be 1.23\n * const result3 = round(1.2345, 3); // result3 will be 1.235\n * const result4 = round(1.2345, 3.1); // This will throw an error\n */\nexport function round(value: number, precision = 0): number {\n if (!Number.isInteger(precision)) {\n throw new Error('Precision must be an integer.');\n }\n const multiplier = Math.pow(10, precision);\n return Math.round(value * multiplier) / multiplier;\n}\n","/**\n * Returns an array of numbers from `start` to `end`, incrementing by `step`.\n *\n * If `step` is not provided, it defaults to `1`.\n *\n * @param {number} start - The starting number of the range (inclusive).\n * @param {number} [end] - The end number of the range (exclusive).\n * @param {number} [step] - The step value for the range. (default: 1)\n * @returns {number[]} An array of numbers from `start` to `end` with the specified `step`.\n *\n * @example\n * // Returns [0, 1, 2, 3]\n * range(4);\n *\n * @example\n * // Returns [0, 5, 10, 15]\n * range(0, 20, 5);\n *\n * @example\n * // Returns [0, -1, -2, -3]\n * range(0, -4, -1);\n *\n * @example\n * // Throws an error: The step value must be a non-zero integer.\n * range(1, 4, 0);\n */\nexport function range(end: number): number[];\nexport function range(start: number, end: number): number[];\nexport function range(start: number, end: number, step: number): number[];\nexport function range(start: number, end?: number, step?: number): number[] {\n if (end == null) {\n end = start;\n start = 0;\n }\n\n if (step == null) {\n step = 1;\n }\n\n if (!Number.isInteger(step) || step === 0) {\n throw new Error(`The step value must be a non-zero integer.`);\n }\n\n const length = Math.max(Math.ceil((end - start) / step), 0);\n const result = new Array(length);\n\n for (let i = 0; i < length; i++) {\n result[i] = start + i * step;\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmBO,SAAS,MAAM,OAAe,QAAgB,QAAyB;AAC5E,MAAI,UAAU,MAAM;AAClB,WAAO,KAAK,IAAI,OAAO,MAAM;AAAA,EAC/B;AAEA,SAAO,KAAK,IAAI,KAAK,IAAI,OAAO,MAAM,GAAG,MAAM;AACjD;;;ACTO,SAAS,QAAQ,OAAe,SAAiB,SAA2B;AACjF,MAAI,WAAW,MAAM;AACnB,cAAU;AACV,cAAU;AAAA,EACZ;AAEA,MAAI,WAAW,SAAS;AACtB,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AAEA,SAAO,WAAW,SAAS,QAAQ;AACrC;;;ACdO,SAAS,IAAI,MAAiC;AACnD,MAAI,SAAS;AAEb,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,cAAU,KAAK,CAAC;AAAA,EAClB;AAEA,SAAO;AACT;;;ACNO,SAAS,KAAK,MAAiC;AACpD,SAAO,IAAI,IAAI,IAAI,KAAK;AAC1B;;;ACAO,SAAS,OAAU,OAAqB,UAA0C;AACvF,QAAM,OAAO,MAAM,IAAI,OAAK,SAAS,CAAC,CAAC;AAEvC,SAAO,KAAK,IAAI;AAClB;;;ACJO,SAAS,OAAO,SAAiB,SAA0B;AAChE,MAAI,WAAW,MAAM;AACnB,cAAU;AACV,cAAU;AAAA,EACZ;AAEA,MAAI,WAAW,SAAS;AACtB,UAAM,IAAI,MAAM,0EAA0E;AAAA,EAC5F;AAEA,SAAO,KAAK,OAAO,KAAK,UAAU,WAAW;AAC/C;;;ACVO,SAAS,UAAU,SAAiB,SAA0B;AACnE,SAAO,KAAK,MAAM,OAAO,SAAS,OAAQ,CAAC;AAC7C;;;ACHO,SAAS,MAAM,OAAe,YAAY,GAAW;AAC1D,MAAI,CAAC,OAAO,UAAU,SAAS,GAAG;AAChC,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AACA,QAAM,aAAa,KAAK,IAAI,IAAI,SAAS;AACzC,SAAO,KAAK,MAAM,QAAQ,UAAU,IAAI;AAC1C;;;ACMO,SAAS,MAAM,OAAe,KAAc,MAAyB;AAC1E,MAAI,OAAO,MAAM;AACf,UAAM;AACN,YAAQ;AAAA,EACV;AAEA,MAAI,QAAQ,MAAM;AAChB,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,OAAO,UAAU,IAAI,KAAK,SAAS,GAAG;AACzC,UAAM,IAAI,MAAM,4CAA4C;AAAA,EAC9D;AAEA,QAAM,SAAS,KAAK,IAAI,KAAK,MAAM,MAAM,SAAS,IAAI,GAAG,CAAC;AAC1D,QAAM,SAAS,IAAI,MAAM,MAAM;AAE/B,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK;AAC/B,WAAO,CAAC,IAAI,QAAQ,IAAI;AAAA,EAC1B;AAEA,SAAO;AACT;","names":[]}
|
package/dist/math/index.mjs
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import "../chunk-TLVQSNOE.mjs";
|
|
2
|
-
import {
|
|
3
|
-
inRange
|
|
4
|
-
} from "../chunk-BH6HLGBA.mjs";
|
|
5
2
|
import {
|
|
6
3
|
meanBy
|
|
7
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-IZAD2S7R.mjs";
|
|
8
5
|
import {
|
|
9
6
|
mean
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import {
|
|
12
|
-
sum
|
|
13
|
-
} from "../chunk-NOFHNJ5C.mjs";
|
|
7
|
+
} from "../chunk-GDC64SYJ.mjs";
|
|
14
8
|
import {
|
|
15
9
|
range
|
|
16
10
|
} from "../chunk-DPH2KE6O.mjs";
|
|
17
11
|
import {
|
|
18
12
|
round
|
|
19
13
|
} from "../chunk-5PMKOZ2F.mjs";
|
|
14
|
+
import {
|
|
15
|
+
sum
|
|
16
|
+
} from "../chunk-2SLTL4KL.mjs";
|
|
20
17
|
import {
|
|
21
18
|
clamp
|
|
22
19
|
} from "../chunk-MLCL773E.mjs";
|
|
20
|
+
import {
|
|
21
|
+
inRange
|
|
22
|
+
} from "../chunk-BH6HLGBA.mjs";
|
|
23
23
|
import {
|
|
24
24
|
randomInt
|
|
25
25
|
} from "../chunk-GIWAOOFY.mjs";
|
|
26
26
|
import {
|
|
27
27
|
random
|
|
28
28
|
} from "../chunk-SYWMYQYJ.mjs";
|
|
29
|
-
import "../chunk-
|
|
29
|
+
import "../chunk-2HIMLZE3.mjs";
|
|
30
30
|
export {
|
|
31
31
|
clamp,
|
|
32
32
|
inRange,
|
package/dist/math/mean.js
CHANGED
package/dist/math/mean.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/math/mean.ts","../../src/math/sum.ts"],"sourcesContent":["import { sum } from './sum.ts';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @param {number[]} nums - An array of numbers to calculate the average.\n * @returns {number} The average of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = average(numbers);\n * // result will be 3\n */\nexport function mean(nums: readonly number[]): number {\n return sum(nums) / nums.length;\n}\n","/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: readonly number[]): number {\n let result = 0;\n\n for (
|
|
1
|
+
{"version":3,"sources":["../../src/math/mean.ts","../../src/math/sum.ts"],"sourcesContent":["import { sum } from './sum.ts';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @param {number[]} nums - An array of numbers to calculate the average.\n * @returns {number} The average of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = average(numbers);\n * // result will be 3\n */\nexport function mean(nums: readonly number[]): number {\n return sum(nums) / nums.length;\n}\n","/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: readonly number[]): number {\n let result = 0;\n\n for (let i = 0; i < nums.length; i++) {\n result += nums[i];\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,SAAS,IAAI,MAAiC;AACnD,MAAI,SAAS;AAEb,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,cAAU,KAAK,CAAC;AAAA,EAClB;AAEA,SAAO;AACT;;;ADNO,SAAS,KAAK,MAAiC;AACpD,SAAO,IAAI,IAAI,IAAI,KAAK;AAC1B;","names":[]}
|
package/dist/math/mean.mjs
CHANGED
package/dist/math/meanBy.js
CHANGED
package/dist/math/meanBy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/math/meanBy.ts","../../src/math/sum.ts","../../src/math/mean.ts"],"sourcesContent":["import { mean } from './mean.ts';\n\n/**\n * Calculates the average of an array of numbers when applying\n * the `getValue` function to each element.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items An array to calculate the average.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {number} The average of all the numbers as determined by the `getValue` function.\n *\n * @example\n * meanBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 2\n * meanBy([], x => x.a); // Returns: NaN\n */\nexport function meanBy<T>(items: readonly T[], getValue: (element: T) => number): number {\n const nums = items.map(x => getValue(x));\n\n return mean(nums);\n}\n","/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: readonly number[]): number {\n let result = 0;\n\n for (
|
|
1
|
+
{"version":3,"sources":["../../src/math/meanBy.ts","../../src/math/sum.ts","../../src/math/mean.ts"],"sourcesContent":["import { mean } from './mean.ts';\n\n/**\n * Calculates the average of an array of numbers when applying\n * the `getValue` function to each element.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items An array to calculate the average.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {number} The average of all the numbers as determined by the `getValue` function.\n *\n * @example\n * meanBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 2\n * meanBy([], x => x.a); // Returns: NaN\n */\nexport function meanBy<T>(items: readonly T[], getValue: (element: T) => number): number {\n const nums = items.map(x => getValue(x));\n\n return mean(nums);\n}\n","/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: readonly number[]): number {\n let result = 0;\n\n for (let i = 0; i < nums.length; i++) {\n result += nums[i];\n }\n\n return result;\n}\n","import { sum } from './sum.ts';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @param {number[]} nums - An array of numbers to calculate the average.\n * @returns {number} The average of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = average(numbers);\n * // result will be 3\n */\nexport function mean(nums: readonly number[]): number {\n return sum(nums) / nums.length;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,SAAS,IAAI,MAAiC;AACnD,MAAI,SAAS;AAEb,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,cAAU,KAAK,CAAC;AAAA,EAClB;AAEA,SAAO;AACT;;;ACNO,SAAS,KAAK,MAAiC;AACpD,SAAO,IAAI,IAAI,IAAI,KAAK;AAC1B;;;AFAO,SAAS,OAAU,OAAqB,UAA0C;AACvF,QAAM,OAAO,MAAM,IAAI,OAAK,SAAS,CAAC,CAAC;AAEvC,SAAO,KAAK,IAAI;AAClB;","names":[]}
|
package/dist/math/meanBy.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
meanBy
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-IZAD2S7R.mjs";
|
|
4
|
+
import "../chunk-GDC64SYJ.mjs";
|
|
5
|
+
import "../chunk-2SLTL4KL.mjs";
|
|
6
|
+
import "../chunk-2HIMLZE3.mjs";
|
|
7
7
|
export {
|
|
8
8
|
meanBy
|
|
9
9
|
};
|
package/dist/math/random.mjs
CHANGED
package/dist/math/randomInt.mjs
CHANGED
package/dist/math/range.mjs
CHANGED
package/dist/math/round.mjs
CHANGED
package/dist/math/sum.js
CHANGED
package/dist/math/sum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/math/sum.ts"],"sourcesContent":["/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: readonly number[]): number {\n let result = 0;\n\n for (
|
|
1
|
+
{"version":3,"sources":["../../src/math/sum.ts"],"sourcesContent":["/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: readonly number[]): number {\n let result = 0;\n\n for (let i = 0; i < nums.length; i++) {\n result += nums[i];\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,IAAI,MAAiC;AACnD,MAAI,SAAS;AAEb,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,cAAU,KAAK,CAAC;AAAA,EAClB;AAEA,SAAO;AACT;","names":[]}
|
package/dist/math/sum.mjs
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a shallow clone of the given object.
|
|
3
|
+
*
|
|
4
|
+
* @template T - The type of the object.
|
|
5
|
+
* @param {T} obj - The object to clone.
|
|
6
|
+
* @returns {T} - A shallow clone of the given object.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Clone a primitive values
|
|
10
|
+
* const num = 29;
|
|
11
|
+
* const clonedNum = clone(num);
|
|
12
|
+
* console.log(clonedNum); // 29
|
|
13
|
+
* console.log(clonedNum === num) ; // true
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Clone an array
|
|
17
|
+
* const arr = [1, 2, 3];
|
|
18
|
+
* const clonedArr = clone(arr);
|
|
19
|
+
* console.log(clonedArr); // [1, 2, 3]
|
|
20
|
+
* console.log(clonedArr === arr); // false
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Clone an object
|
|
24
|
+
* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
|
|
25
|
+
* const clonedObj = clone(obj);
|
|
26
|
+
* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
|
|
27
|
+
* console.log(clonedObj === obj); // false
|
|
28
|
+
*/
|
|
29
|
+
declare function clone<T>(obj: T): T;
|
|
30
|
+
|
|
31
|
+
export { clone };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a shallow clone of the given object.
|
|
3
|
+
*
|
|
4
|
+
* @template T - The type of the object.
|
|
5
|
+
* @param {T} obj - The object to clone.
|
|
6
|
+
* @returns {T} - A shallow clone of the given object.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Clone a primitive values
|
|
10
|
+
* const num = 29;
|
|
11
|
+
* const clonedNum = clone(num);
|
|
12
|
+
* console.log(clonedNum); // 29
|
|
13
|
+
* console.log(clonedNum === num) ; // true
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Clone an array
|
|
17
|
+
* const arr = [1, 2, 3];
|
|
18
|
+
* const clonedArr = clone(arr);
|
|
19
|
+
* console.log(clonedArr); // [1, 2, 3]
|
|
20
|
+
* console.log(clonedArr === arr); // false
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Clone an object
|
|
24
|
+
* const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
|
|
25
|
+
* const clonedObj = clone(obj);
|
|
26
|
+
* console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
|
|
27
|
+
* console.log(clonedObj === obj); // false
|
|
28
|
+
*/
|
|
29
|
+
declare function clone<T>(obj: T): T;
|
|
30
|
+
|
|
31
|
+
export { clone };
|