es-toolkit 1.13.1-dev.320 → 1.13.1-dev.322
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/dist/array/chunk.mjs +1 -1
- package/dist/array/compact.d.mts +1 -1
- package/dist/array/compact.d.ts +1 -1
- package/dist/array/compact.js.map +1 -1
- package/dist/array/compact.mjs +2 -2
- package/dist/array/countBy.js +1 -2
- package/dist/array/countBy.js.map +1 -1
- package/dist/array/countBy.mjs +2 -2
- 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.d.mts +1 -0
- package/dist/array/fill.d.ts +1 -0
- package/dist/array/fill.js.map +1 -1
- package/dist/array/fill.mjs +2 -2
- package/dist/array/flatMap.mjs +1 -1
- package/dist/array/flatten.mjs +1 -1
- package/dist/array/flattenDeep.mjs +1 -1
- package/dist/array/forEachRight.mjs +1 -1
- package/dist/array/groupBy.mjs +1 -1
- package/dist/array/head.d.mts +1 -0
- package/dist/array/head.d.ts +1 -0
- package/dist/array/head.js.map +1 -1
- package/dist/array/head.mjs +2 -2
- package/dist/array/index.js +1 -2
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +56 -56
- package/dist/array/initial.mjs +1 -1
- 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 +1 -0
- package/dist/array/last.d.ts +1 -0
- package/dist/array/last.js.map +1 -1
- package/dist/array/last.mjs +2 -2
- 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.d.mts +9 -4
- package/dist/array/tail.d.ts +9 -4
- package/dist/array/tail.js.map +1 -1
- package/dist/array/tail.mjs +2 -2
- 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 +2 -0
- package/dist/array/toFilled.d.ts +2 -0
- package/dist/array/toFilled.js.map +1 -1
- package/dist/array/toFilled.mjs +2 -2
- 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.d.mts +3 -2
- package/dist/array/unzip.d.ts +3 -2
- package/dist/array/unzip.js.map +1 -1
- package/dist/array/unzip.mjs +2 -2
- 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.d.mts +5 -0
- package/dist/array/zipWith.d.ts +5 -0
- package/dist/array/zipWith.js.map +1 -1
- package/dist/array/zipWith.mjs +2 -2
- package/dist/browser.js +22 -58
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +54 -53
- package/dist/browser.mjs.map +1 -1
- package/dist/{chunk-QXTNZR7B.mjs → chunk-3SBT6WDU.mjs} +2 -2
- package/dist/{chunk-O64NE2P4.mjs → chunk-4DFAGGIM.mjs} +3 -3
- package/dist/{chunk-O64NE2P4.mjs.map → chunk-4DFAGGIM.mjs.map} +1 -1
- package/dist/{chunk-Y5V7UAZZ.mjs → chunk-4ZES5T6V.mjs} +4 -4
- package/dist/{chunk-TJ4Z5I7M.mjs → chunk-DLS7UJKJ.mjs} +1 -1
- package/dist/chunk-DLS7UJKJ.mjs.map +1 -0
- package/dist/{chunk-KPBQ7OUY.mjs → chunk-DTTKJ3VC.mjs} +1 -1
- package/dist/chunk-DTTKJ3VC.mjs.map +1 -0
- package/dist/{chunk-YNJH6GEG.mjs → chunk-EEHJ656S.mjs} +95 -92
- package/dist/chunk-EEHJ656S.mjs.map +1 -0
- package/dist/{chunk-EYYZQFOP.mjs → chunk-ET33L3MQ.mjs} +2 -2
- package/dist/chunk-EZYYB34V.mjs +17 -0
- package/dist/{chunk-CVVZHOJX.mjs.map → chunk-EZYYB34V.mjs.map} +1 -1
- package/dist/{chunk-HM2JT2RX.mjs → chunk-FZZNWXDM.mjs} +1 -1
- package/dist/chunk-FZZNWXDM.mjs.map +1 -0
- package/dist/{chunk-YFN6KOC4.mjs → chunk-GTFDDKZ2.mjs} +1 -1
- package/dist/chunk-GTFDDKZ2.mjs.map +1 -0
- package/dist/{chunk-F3WCQQET.mjs → chunk-IWXZI3QT.mjs} +2 -2
- package/dist/chunk-J5LGTIGS.mjs +10 -0
- package/dist/{chunk-UYZKMBDO.mjs → chunk-JCRY7ZYS.mjs} +1 -1
- package/dist/chunk-JCRY7ZYS.mjs.map +1 -0
- package/dist/{chunk-5CPXZFCB.mjs → chunk-K5WL54BY.mjs} +2 -2
- package/dist/{chunk-5CPXZFCB.mjs.map → chunk-K5WL54BY.mjs.map} +1 -1
- package/dist/{chunk-4KYXHZ4R.mjs → chunk-MJ7LNBI6.mjs} +1 -1
- package/dist/chunk-MJ7LNBI6.mjs.map +1 -0
- package/dist/{chunk-3IP4JVLL.mjs → chunk-MSHSKENG.mjs} +3 -3
- package/dist/{chunk-3IP4JVLL.mjs.map → chunk-MSHSKENG.mjs.map} +1 -1
- package/dist/{chunk-WVQ7YVRK.mjs → chunk-OG2RLT5U.mjs} +2 -3
- package/dist/{chunk-WVQ7YVRK.mjs.map → chunk-OG2RLT5U.mjs.map} +1 -1
- package/dist/{chunk-DTJJIMKJ.mjs → chunk-PJPGJ2O6.mjs} +1 -1
- package/dist/chunk-PJPGJ2O6.mjs.map +1 -0
- package/dist/chunk-R6GLTTAB.mjs +9 -0
- package/dist/chunk-R6GLTTAB.mjs.map +1 -0
- package/dist/{chunk-5IKVJGHO.mjs → chunk-RTFTLCF3.mjs} +2 -2
- package/dist/{chunk-OP4OAKQJ.mjs → chunk-XHSIT5DL.mjs} +1 -1
- package/dist/chunk-XHSIT5DL.mjs.map +1 -0
- package/dist/{chunk-WFZXCGEG.mjs → chunk-YOPFSFTD.mjs} +2 -6
- package/dist/{chunk-WFZXCGEG.mjs.map → chunk-YOPFSFTD.mjs.map} +1 -1
- package/dist/chunk-YXD3AQAK.mjs +1 -0
- package/dist/{chunk-CRSKT4WW.mjs → chunk-Z7HWEOQX.mjs} +2 -3
- package/dist/{chunk-CRSKT4WW.mjs.map → chunk-Z7HWEOQX.mjs.map} +1 -1
- package/dist/chunk-ZPNX2QDE.mjs +13 -0
- package/dist/{chunk-IIDZ3KAJ.mjs.map → chunk-ZPNX2QDE.mjs.map} +1 -1
- package/dist/compat/index.d.mts +3 -1
- package/dist/compat/index.d.ts +3 -1
- package/dist/compat/index.js +23 -57
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +98 -94
- package/dist/error/AbortError.mjs +1 -1
- package/dist/error/TimeoutError.mjs +1 -1
- package/dist/error/index.mjs +4 -4
- package/dist/function/after.mjs +1 -1
- package/dist/function/debounce.js +2 -2
- package/dist/function/debounce.js.map +1 -1
- package/dist/function/debounce.mjs +2 -2
- package/dist/function/index.js +2 -2
- package/dist/function/index.js.map +1 -1
- package/dist/function/index.mjs +10 -10
- package/dist/function/negate.mjs +1 -1
- 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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -93
- package/dist/math/clamp.mjs +1 -1
- package/dist/math/inRange.mjs +1 -1
- package/dist/math/index.mjs +1 -1
- package/dist/math/mean.mjs +1 -1
- package/dist/math/meanBy.mjs +1 -1
- 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.mjs +1 -1
- package/dist/math/sumBy.mjs +1 -1
- package/dist/object/clone.mjs +1 -1
- package/dist/object/cloneDeep.js +1 -1
- package/dist/object/cloneDeep.js.map +1 -1
- package/dist/object/cloneDeep.mjs +2 -2
- package/dist/object/flattenObject.mjs +1 -1
- package/dist/object/index.js +2 -16
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +3 -3
- package/dist/object/invert.mjs +1 -1
- package/dist/object/omit.js +1 -15
- package/dist/object/omit.js.map +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 +7 -0
- package/dist/predicate/index.js.map +1 -1
- package/dist/predicate/index.mjs +9 -5
- package/dist/predicate/isArrayLike.mjs +1 -1
- package/dist/predicate/isEqual.mjs +1 -1
- package/dist/predicate/isFunction.mjs +1 -1
- package/dist/predicate/isLength.mjs +1 -1
- package/dist/predicate/isNil.mjs +1 -1
- package/dist/predicate/isNotNil.mjs +1 -1
- package/dist/predicate/isNull.mjs +1 -1
- package/dist/predicate/isPlainObject.mjs +1 -1
- package/dist/predicate/isPrimitive.d.mts +17 -0
- package/dist/predicate/isPrimitive.d.ts +17 -0
- package/dist/predicate/isPrimitive.js +33 -0
- package/dist/predicate/isPrimitive.js.map +1 -0
- package/dist/predicate/isPrimitive.mjs +8 -0
- package/dist/predicate/isPrimitive.mjs.map +1 -0
- package/dist/predicate/isTypedArray.mjs +1 -1
- package/dist/predicate/isUndefined.mjs +1 -1
- package/dist/promise/delay.js +2 -2
- package/dist/promise/delay.js.map +1 -1
- package/dist/promise/delay.mjs +2 -2
- package/dist/promise/index.js +7 -31
- package/dist/promise/index.js.map +1 -1
- package/dist/promise/index.mjs +5 -5
- package/dist/promise/timeout.js +5 -27
- package/dist/promise/timeout.js.map +1 -1
- package/dist/promise/timeout.mjs +4 -4
- package/dist/promise/withTimeout.js +7 -31
- package/dist/promise/withTimeout.js.map +1 -1
- package/dist/promise/withTimeout.mjs +5 -5
- package/dist/string/camelCase.js +1 -2
- package/dist/string/camelCase.js.map +1 -1
- package/dist/string/camelCase.mjs +3 -3
- package/dist/string/capitalize.mjs +1 -1
- package/dist/string/index.js +1 -2
- package/dist/string/index.js.map +1 -1
- package/dist/string/index.mjs +9 -9
- package/dist/string/kebabCase.js +1 -2
- package/dist/string/kebabCase.js.map +1 -1
- package/dist/string/kebabCase.mjs +3 -3
- package/dist/string/lowerCase.js +1 -2
- package/dist/string/lowerCase.js.map +1 -1
- package/dist/string/lowerCase.mjs +3 -3
- package/dist/string/snakeCase.js +1 -2
- package/dist/string/snakeCase.js.map +1 -1
- package/dist/string/snakeCase.mjs +3 -3
- package/dist/string/startCase.js +1 -2
- package/dist/string/startCase.js.map +1 -1
- package/dist/string/startCase.mjs +3 -3
- package/package.json +1 -1
- package/umd/browser.global.js +1 -1
- package/dist/chunk-24FKGR6U.mjs +0 -47
- package/dist/chunk-4KYXHZ4R.mjs.map +0 -1
- package/dist/chunk-CVVZHOJX.mjs +0 -22
- package/dist/chunk-DTJJIMKJ.mjs.map +0 -1
- package/dist/chunk-HM2JT2RX.mjs.map +0 -1
- package/dist/chunk-IIDZ3KAJ.mjs +0 -18
- package/dist/chunk-KPBQ7OUY.mjs.map +0 -1
- package/dist/chunk-OP4OAKQJ.mjs.map +0 -1
- package/dist/chunk-STL6TD3L.mjs +0 -1
- package/dist/chunk-TJ4Z5I7M.mjs.map +0 -1
- package/dist/chunk-UYZKMBDO.mjs.map +0 -1
- package/dist/chunk-YFN6KOC4.mjs.map +0 -1
- package/dist/chunk-YNJH6GEG.mjs.map +0 -1
- /package/dist/{chunk-QXTNZR7B.mjs.map → chunk-3SBT6WDU.mjs.map} +0 -0
- /package/dist/{chunk-Y5V7UAZZ.mjs.map → chunk-4ZES5T6V.mjs.map} +0 -0
- /package/dist/{chunk-EYYZQFOP.mjs.map → chunk-ET33L3MQ.mjs.map} +0 -0
- /package/dist/{chunk-F3WCQQET.mjs.map → chunk-IWXZI3QT.mjs.map} +0 -0
- /package/dist/{chunk-24FKGR6U.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/{chunk-5IKVJGHO.mjs.map → chunk-RTFTLCF3.mjs.map} +0 -0
- /package/dist/{chunk-STL6TD3L.mjs.map → chunk-YXD3AQAK.mjs.map} +0 -0
package/dist/compat/index.mjs
CHANGED
|
@@ -13,37 +13,40 @@ import {
|
|
|
13
13
|
set,
|
|
14
14
|
startsWith,
|
|
15
15
|
zipObjectDeep
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-EEHJ656S.mjs";
|
|
17
17
|
import "../chunk-NKLIE2OI.mjs";
|
|
18
18
|
import "../chunk-4OIZM4HS.mjs";
|
|
19
19
|
import {
|
|
20
20
|
withTimeout
|
|
21
|
-
} from "../chunk-
|
|
22
|
-
import "../chunk-
|
|
21
|
+
} from "../chunk-ZPNX2QDE.mjs";
|
|
22
|
+
import "../chunk-EZYYB34V.mjs";
|
|
23
23
|
import {
|
|
24
24
|
delay
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-4DFAGGIM.mjs";
|
|
26
26
|
import "../chunk-XT74R35S.mjs";
|
|
27
|
+
import {
|
|
28
|
+
kebabCase
|
|
29
|
+
} from "../chunk-ET33L3MQ.mjs";
|
|
27
30
|
import {
|
|
28
31
|
lowerCase
|
|
29
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-RTFTLCF3.mjs";
|
|
30
33
|
import {
|
|
31
34
|
snakeCase
|
|
32
|
-
} from "../chunk-
|
|
35
|
+
} from "../chunk-IWXZI3QT.mjs";
|
|
33
36
|
import {
|
|
34
37
|
startCase
|
|
35
|
-
} from "../chunk-
|
|
38
|
+
} from "../chunk-3SBT6WDU.mjs";
|
|
36
39
|
import {
|
|
37
40
|
camelCase
|
|
38
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-4ZES5T6V.mjs";
|
|
42
|
+
import "../chunk-OG2RLT5U.mjs";
|
|
39
43
|
import {
|
|
40
44
|
capitalize
|
|
41
45
|
} from "../chunk-U56ZOM7L.mjs";
|
|
46
|
+
import "../chunk-YXD3AQAK.mjs";
|
|
42
47
|
import {
|
|
43
|
-
|
|
44
|
-
} from "../chunk-
|
|
45
|
-
import "../chunk-WVQ7YVRK.mjs";
|
|
46
|
-
import "../chunk-STL6TD3L.mjs";
|
|
48
|
+
isUndefined
|
|
49
|
+
} from "../chunk-VH2PV426.mjs";
|
|
47
50
|
import {
|
|
48
51
|
isFunction
|
|
49
52
|
} from "../chunk-74CREQXW.mjs";
|
|
@@ -56,10 +59,10 @@ import {
|
|
|
56
59
|
import {
|
|
57
60
|
isNull
|
|
58
61
|
} from "../chunk-AIRSKN47.mjs";
|
|
59
|
-
import "../chunk-SXFMQQ6F.mjs";
|
|
60
62
|
import {
|
|
61
|
-
|
|
62
|
-
} from "../chunk-
|
|
63
|
+
isPrimitive
|
|
64
|
+
} from "../chunk-R6GLTTAB.mjs";
|
|
65
|
+
import "../chunk-SXFMQQ6F.mjs";
|
|
63
66
|
import {
|
|
64
67
|
isArrayLike
|
|
65
68
|
} from "../chunk-LPZZIY5Z.mjs";
|
|
@@ -75,7 +78,7 @@ import {
|
|
|
75
78
|
} from "../chunk-OLX53VEF.mjs";
|
|
76
79
|
import {
|
|
77
80
|
omit
|
|
78
|
-
} from "../chunk-
|
|
81
|
+
} from "../chunk-YOPFSFTD.mjs";
|
|
79
82
|
import {
|
|
80
83
|
omitBy
|
|
81
84
|
} from "../chunk-BCTYOXT7.mjs";
|
|
@@ -90,7 +93,7 @@ import {
|
|
|
90
93
|
} from "../chunk-VRUTBJYS.mjs";
|
|
91
94
|
import {
|
|
92
95
|
cloneDeep
|
|
93
|
-
} from "../chunk-
|
|
96
|
+
} from "../chunk-K5WL54BY.mjs";
|
|
94
97
|
import {
|
|
95
98
|
flattenObject
|
|
96
99
|
} from "../chunk-XGQWTHW6.mjs";
|
|
@@ -120,33 +123,19 @@ import {
|
|
|
120
123
|
import {
|
|
121
124
|
sum
|
|
122
125
|
} from "../chunk-2SLTL4KL.mjs";
|
|
123
|
-
import "../chunk-
|
|
124
|
-
import {
|
|
125
|
-
TimeoutError
|
|
126
|
-
} from "../chunk-KIOYQRMQ.mjs";
|
|
127
|
-
import "../chunk-ZA2XI3OV.mjs";
|
|
128
|
-
import {
|
|
129
|
-
throttle
|
|
130
|
-
} from "../chunk-QOJGMVVR.mjs";
|
|
131
|
-
import {
|
|
132
|
-
after
|
|
133
|
-
} from "../chunk-OGZMEWPR.mjs";
|
|
134
|
-
import {
|
|
135
|
-
debounce
|
|
136
|
-
} from "../chunk-3IP4JVLL.mjs";
|
|
126
|
+
import "../chunk-DDH7K4QM.mjs";
|
|
137
127
|
import {
|
|
138
|
-
|
|
139
|
-
} from "../chunk-
|
|
128
|
+
zipWith
|
|
129
|
+
} from "../chunk-MJ7LNBI6.mjs";
|
|
140
130
|
import {
|
|
141
|
-
|
|
142
|
-
} from "../chunk-
|
|
131
|
+
unzip
|
|
132
|
+
} from "../chunk-JCRY7ZYS.mjs";
|
|
143
133
|
import {
|
|
144
|
-
|
|
145
|
-
} from "../chunk-
|
|
134
|
+
unzipWith
|
|
135
|
+
} from "../chunk-IFNXROZR.mjs";
|
|
146
136
|
import {
|
|
147
|
-
|
|
148
|
-
} from "../chunk-
|
|
149
|
-
import "../chunk-DDH7K4QM.mjs";
|
|
137
|
+
without
|
|
138
|
+
} from "../chunk-PYEYV7BY.mjs";
|
|
150
139
|
import {
|
|
151
140
|
xor
|
|
152
141
|
} from "../chunk-L7FQX5MN.mjs";
|
|
@@ -163,14 +152,23 @@ import {
|
|
|
163
152
|
zipObject
|
|
164
153
|
} from "../chunk-6GWEY5EL.mjs";
|
|
165
154
|
import {
|
|
166
|
-
|
|
167
|
-
} from "../chunk-
|
|
155
|
+
takeWhile
|
|
156
|
+
} from "../chunk-2IXFGSUA.mjs";
|
|
157
|
+
import {
|
|
158
|
+
toFilled
|
|
159
|
+
} from "../chunk-XHSIT5DL.mjs";
|
|
160
|
+
import {
|
|
161
|
+
union
|
|
162
|
+
} from "../chunk-R6QA7PLZ.mjs";
|
|
168
163
|
import {
|
|
169
164
|
unionBy
|
|
170
165
|
} from "../chunk-NFS7RWWE.mjs";
|
|
171
166
|
import {
|
|
172
167
|
unionWith
|
|
173
168
|
} from "../chunk-2ZCITDMK.mjs";
|
|
169
|
+
import {
|
|
170
|
+
uniq
|
|
171
|
+
} from "../chunk-DVK2N4KC.mjs";
|
|
174
172
|
import {
|
|
175
173
|
uniqBy
|
|
176
174
|
} from "../chunk-B4COTK4K.mjs";
|
|
@@ -178,20 +176,26 @@ import {
|
|
|
178
176
|
uniqWith
|
|
179
177
|
} from "../chunk-237HGSZS.mjs";
|
|
180
178
|
import {
|
|
181
|
-
|
|
182
|
-
} from "../chunk-
|
|
179
|
+
partition
|
|
180
|
+
} from "../chunk-DN3NOZ3H.mjs";
|
|
183
181
|
import {
|
|
184
|
-
|
|
185
|
-
} from "../chunk-
|
|
182
|
+
sample
|
|
183
|
+
} from "../chunk-2KNLZB7V.mjs";
|
|
186
184
|
import {
|
|
187
|
-
|
|
188
|
-
} from "../chunk-
|
|
185
|
+
sampleSize
|
|
186
|
+
} from "../chunk-EHSKB6DF.mjs";
|
|
187
|
+
import {
|
|
188
|
+
randomInt
|
|
189
|
+
} from "../chunk-GIWAOOFY.mjs";
|
|
190
|
+
import {
|
|
191
|
+
random
|
|
192
|
+
} from "../chunk-SYWMYQYJ.mjs";
|
|
189
193
|
import {
|
|
190
194
|
shuffle
|
|
191
195
|
} from "../chunk-G7UQ5PUR.mjs";
|
|
192
196
|
import {
|
|
193
197
|
tail
|
|
194
|
-
} from "../chunk-
|
|
198
|
+
} from "../chunk-DLS7UJKJ.mjs";
|
|
195
199
|
import {
|
|
196
200
|
take
|
|
197
201
|
} from "../chunk-ME352XO7.mjs";
|
|
@@ -202,23 +206,20 @@ import {
|
|
|
202
206
|
takeRightWhile
|
|
203
207
|
} from "../chunk-NTLX2MPV.mjs";
|
|
204
208
|
import {
|
|
205
|
-
|
|
206
|
-
} from "../chunk-
|
|
207
|
-
import {
|
|
208
|
-
toFilled
|
|
209
|
-
} from "../chunk-OP4OAKQJ.mjs";
|
|
209
|
+
intersection
|
|
210
|
+
} from "../chunk-FVVSE2F2.mjs";
|
|
210
211
|
import {
|
|
211
|
-
|
|
212
|
-
} from "../chunk-
|
|
212
|
+
intersectionBy
|
|
213
|
+
} from "../chunk-O6UXZR3U.mjs";
|
|
213
214
|
import {
|
|
214
|
-
|
|
215
|
-
} from "../chunk-
|
|
215
|
+
intersectionWith
|
|
216
|
+
} from "../chunk-XI7KRD2C.mjs";
|
|
216
217
|
import {
|
|
217
218
|
keyBy
|
|
218
219
|
} from "../chunk-AJKZMN2V.mjs";
|
|
219
220
|
import {
|
|
220
221
|
last
|
|
221
|
-
} from "../chunk-
|
|
222
|
+
} from "../chunk-DTTKJ3VC.mjs";
|
|
222
223
|
import {
|
|
223
224
|
maxBy
|
|
224
225
|
} from "../chunk-OOKNBU4V.mjs";
|
|
@@ -229,20 +230,14 @@ import {
|
|
|
229
230
|
orderBy
|
|
230
231
|
} from "../chunk-7B7W36UP.mjs";
|
|
231
232
|
import {
|
|
232
|
-
|
|
233
|
-
} from "../chunk-
|
|
234
|
-
import {
|
|
235
|
-
sample
|
|
236
|
-
} from "../chunk-2KNLZB7V.mjs";
|
|
237
|
-
import {
|
|
238
|
-
sampleSize
|
|
239
|
-
} from "../chunk-EHSKB6DF.mjs";
|
|
233
|
+
flatMap
|
|
234
|
+
} from "../chunk-UY76KTPE.mjs";
|
|
240
235
|
import {
|
|
241
|
-
|
|
242
|
-
} from "../chunk-
|
|
236
|
+
flattenDeep
|
|
237
|
+
} from "../chunk-ML727RRJ.mjs";
|
|
243
238
|
import {
|
|
244
|
-
|
|
245
|
-
} from "../chunk-
|
|
239
|
+
flatten
|
|
240
|
+
} from "../chunk-33MSBDC6.mjs";
|
|
246
241
|
import {
|
|
247
242
|
forEachRight
|
|
248
243
|
} from "../chunk-IEA53J7P.mjs";
|
|
@@ -251,19 +246,17 @@ import {
|
|
|
251
246
|
} from "../chunk-E6E4RZLN.mjs";
|
|
252
247
|
import {
|
|
253
248
|
head
|
|
254
|
-
} from "../chunk-
|
|
249
|
+
} from "../chunk-FZZNWXDM.mjs";
|
|
255
250
|
import {
|
|
256
251
|
initial
|
|
257
252
|
} from "../chunk-XPSOKBRZ.mjs";
|
|
253
|
+
import "../chunk-JPUKH67K.mjs";
|
|
258
254
|
import {
|
|
259
|
-
|
|
260
|
-
} from "../chunk-
|
|
261
|
-
import {
|
|
262
|
-
intersectionBy
|
|
263
|
-
} from "../chunk-O6UXZR3U.mjs";
|
|
255
|
+
differenceBy
|
|
256
|
+
} from "../chunk-LVWX5B43.mjs";
|
|
264
257
|
import {
|
|
265
|
-
|
|
266
|
-
} from "../chunk-
|
|
258
|
+
differenceWith
|
|
259
|
+
} from "../chunk-6NVQAHXP.mjs";
|
|
267
260
|
import {
|
|
268
261
|
drop
|
|
269
262
|
} from "../chunk-3EZAFZG3.mjs";
|
|
@@ -276,31 +269,41 @@ import {
|
|
|
276
269
|
import {
|
|
277
270
|
dropWhile
|
|
278
271
|
} from "../chunk-LJ2C6MVP.mjs";
|
|
279
|
-
import "../chunk-
|
|
272
|
+
import "../chunk-GTFDDKZ2.mjs";
|
|
273
|
+
import "../chunk-ZA2XI3OV.mjs";
|
|
280
274
|
import {
|
|
281
|
-
|
|
282
|
-
} from "../chunk-
|
|
275
|
+
negate
|
|
276
|
+
} from "../chunk-BOOQBJN2.mjs";
|
|
283
277
|
import {
|
|
284
|
-
|
|
285
|
-
} from "../chunk-
|
|
278
|
+
noop
|
|
279
|
+
} from "../chunk-LKXCOLNY.mjs";
|
|
286
280
|
import {
|
|
287
|
-
|
|
288
|
-
} from "../chunk-
|
|
281
|
+
once
|
|
282
|
+
} from "../chunk-CMBC4MXG.mjs";
|
|
283
|
+
import {
|
|
284
|
+
throttle
|
|
285
|
+
} from "../chunk-QOJGMVVR.mjs";
|
|
289
286
|
import "../chunk-E6C5EZQA.mjs";
|
|
290
287
|
import {
|
|
291
288
|
compact
|
|
292
|
-
} from "../chunk-
|
|
289
|
+
} from "../chunk-PJPGJ2O6.mjs";
|
|
293
290
|
import {
|
|
294
291
|
countBy
|
|
295
|
-
} from "../chunk-
|
|
296
|
-
import "../chunk-
|
|
292
|
+
} from "../chunk-Z7HWEOQX.mjs";
|
|
293
|
+
import "../chunk-F47GLYUU.mjs";
|
|
297
294
|
import {
|
|
298
|
-
|
|
299
|
-
} from "../chunk-
|
|
295
|
+
AbortError
|
|
296
|
+
} from "../chunk-DXB7EZUQ.mjs";
|
|
300
297
|
import {
|
|
301
|
-
|
|
302
|
-
} from "../chunk-
|
|
303
|
-
import
|
|
298
|
+
TimeoutError
|
|
299
|
+
} from "../chunk-KIOYQRMQ.mjs";
|
|
300
|
+
import {
|
|
301
|
+
after
|
|
302
|
+
} from "../chunk-OGZMEWPR.mjs";
|
|
303
|
+
import {
|
|
304
|
+
debounce
|
|
305
|
+
} from "../chunk-MSHSKENG.mjs";
|
|
306
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
304
307
|
export {
|
|
305
308
|
AbortError,
|
|
306
309
|
TimeoutError,
|
|
@@ -349,6 +352,7 @@ export {
|
|
|
349
352
|
isNotNil,
|
|
350
353
|
isNull,
|
|
351
354
|
isPlainObject,
|
|
355
|
+
isPrimitive,
|
|
352
356
|
isTypedArray,
|
|
353
357
|
isUndefined,
|
|
354
358
|
kebabCase,
|
package/dist/error/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "../chunk-F47GLYUU.mjs";
|
|
2
|
-
import {
|
|
3
|
-
TimeoutError
|
|
4
|
-
} from "../chunk-KIOYQRMQ.mjs";
|
|
5
2
|
import {
|
|
6
3
|
AbortError
|
|
7
4
|
} from "../chunk-DXB7EZUQ.mjs";
|
|
8
|
-
import
|
|
5
|
+
import {
|
|
6
|
+
TimeoutError
|
|
7
|
+
} from "../chunk-KIOYQRMQ.mjs";
|
|
8
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
9
9
|
export {
|
|
10
10
|
AbortError,
|
|
11
11
|
TimeoutError
|
package/dist/function/after.mjs
CHANGED
|
@@ -29,7 +29,7 @@ function debounce(func, debounceMs, { signal } = {}) {
|
|
|
29
29
|
if (timeoutId !== null) {
|
|
30
30
|
clearTimeout(timeoutId);
|
|
31
31
|
}
|
|
32
|
-
if (signal
|
|
32
|
+
if (signal?.aborted) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
timeoutId = setTimeout(() => {
|
|
@@ -46,7 +46,7 @@ function debounce(func, debounceMs, { signal } = {}) {
|
|
|
46
46
|
timeoutId = null;
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
signal
|
|
49
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
50
50
|
return debounced;
|
|
51
51
|
}
|
|
52
52
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/function/debounce.ts"],"sourcesContent":["interface DebounceOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * @template F - The type of function.\n * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @param {DebounceOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.\n * @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.\n *\n * @example\n * const debouncedFunction = debounce(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' after 1 second if not called again in that time\n * debouncedFunction();\n *\n * // Will not log anything as the previous call is canceled\n * debouncedFunction.cancel();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const signal = controller.signal;\n * const debouncedWithSignal = debounce(() => {\n * console.log('Function executed');\n * }, 1000, { signal });\n *\n * debouncedWithSignal();\n *\n * // Will cancel the debounced function call\n * controller.abort();\n */\nexport function debounce<F extends (...args: any[]) => void>(\n func: F,\n debounceMs: number,\n { signal }: DebounceOptions = {}\n): F & { cancel: () => void } {\n let timeoutId: number | null = null;\n\n const debounced = function (...args: Parameters<F>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (signal?.aborted) {\n return;\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n timeoutId = null;\n }, debounceMs) as any;\n } as F & { cancel: () => void };\n\n const onAbort = function () {\n debounced.cancel();\n };\n\n debounced.cancel = function () {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n signal?.addEventListener('abort', onAbort, { once: true });\n\n return debounced;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuCO,SAAS,SACd,MACA,YACA,EAAE,OAAO,IAAqB,CAAC,GACH;AAC5B,MAAI,YAA2B;AAE/B,QAAM,YAAY,YAAa,MAAqB;AAClD,QAAI,cAAc,MAAM;AACtB,mBAAa,SAAS;AAAA,IACxB;AAEA,QAAI,
|
|
1
|
+
{"version":3,"sources":["../../src/function/debounce.ts"],"sourcesContent":["interface DebounceOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * @template F - The type of function.\n * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @param {DebounceOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.\n * @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.\n *\n * @example\n * const debouncedFunction = debounce(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' after 1 second if not called again in that time\n * debouncedFunction();\n *\n * // Will not log anything as the previous call is canceled\n * debouncedFunction.cancel();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const signal = controller.signal;\n * const debouncedWithSignal = debounce(() => {\n * console.log('Function executed');\n * }, 1000, { signal });\n *\n * debouncedWithSignal();\n *\n * // Will cancel the debounced function call\n * controller.abort();\n */\nexport function debounce<F extends (...args: any[]) => void>(\n func: F,\n debounceMs: number,\n { signal }: DebounceOptions = {}\n): F & { cancel: () => void } {\n let timeoutId: number | null = null;\n\n const debounced = function (...args: Parameters<F>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (signal?.aborted) {\n return;\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n timeoutId = null;\n }, debounceMs) as any;\n } as F & { cancel: () => void };\n\n const onAbort = function () {\n debounced.cancel();\n };\n\n debounced.cancel = function () {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n signal?.addEventListener('abort', onAbort, { once: true });\n\n return debounced;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuCO,SAAS,SACd,MACA,YACA,EAAE,OAAO,IAAqB,CAAC,GACH;AAC5B,MAAI,YAA2B;AAE/B,QAAM,YAAY,YAAa,MAAqB;AAClD,QAAI,cAAc,MAAM;AACtB,mBAAa,SAAS;AAAA,IACxB;AAEA,QAAI,QAAQ,SAAS;AACnB;AAAA,IACF;AAEA,gBAAY,WAAW,MAAM;AAC3B,WAAK,GAAG,IAAI;AACZ,kBAAY;AAAA,IACd,GAAG,UAAU;AAAA,EACf;AAEA,QAAM,UAAU,WAAY;AAC1B,cAAU,OAAO;AAAA,EACnB;AAEA,YAAU,SAAS,WAAY;AAC7B,QAAI,cAAc,MAAM;AACtB,mBAAa,SAAS;AACtB,kBAAY;AAAA,IACd;AAAA,EACF;AAEA,UAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;AAEzD,SAAO;AACT;","names":[]}
|
package/dist/function/index.js
CHANGED
|
@@ -50,7 +50,7 @@ function debounce(func, debounceMs, { signal } = {}) {
|
|
|
50
50
|
if (timeoutId !== null) {
|
|
51
51
|
clearTimeout(timeoutId);
|
|
52
52
|
}
|
|
53
|
-
if (signal
|
|
53
|
+
if (signal?.aborted) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
timeoutId = setTimeout(() => {
|
|
@@ -67,7 +67,7 @@ function debounce(func, debounceMs, { signal } = {}) {
|
|
|
67
67
|
timeoutId = null;
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
-
signal
|
|
70
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
71
71
|
return debounced;
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/function/index.ts","../../src/function/after.ts","../../src/function/debounce.ts","../../src/function/noop.ts","../../src/function/once.ts","../../src/function/throttle.ts","../../src/function/negate.ts"],"sourcesContent":["export { after } from './after.ts';\nexport { debounce } from './debounce.ts';\nexport { noop } from './noop.ts';\nexport { once } from './once.ts';\nexport { throttle } from './throttle.ts';\nexport { negate } from './negate.ts';\n","/**\n * Creates a function that only executes starting from the `n`-th call.\n * The provided function will be invoked starting from the `n`-th call.\n *\n * This is particularly useful for scenarios involving events or asynchronous operations\n * where an action should occur only after a certain number of invocations.\n *\n * @template F - The type of the function to be invoked.\n * @param {number} n - The number of calls required for `func` to execute.\n * @param {F} func - The function to be invoked.\n * @returns {F} - A new function that:\n * - Tracks the number of calls.\n * - Invokes `func` starting from the `n`-th call.\n * - Returns `undefined` if fewer than `n` calls have been made.\n * @throws {Error} - Throws an error if `n` is negative.\n * @example\n *\n * const afterFn = after(3, () => {\n * console.log(\"called\")\n * });\n *\n * // Will not log anything.\n * afterFn()\n * // Will not log anything.\n * afterFn()\n * // Will log 'called'.\n * afterFn()\n */\n\nexport const after = <F extends (...args: any[]) => any>(n: number, func: F): F => {\n if (!Number.isInteger(n) || n < 0) {\n throw new Error(`n must be a non-negative integer.`);\n }\n\n let counter = 0;\n return ((...args: Parameters<F>) => {\n if (++counter >= n) {\n return func(...args);\n }\n return undefined;\n }) as F;\n};\n","interface DebounceOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * @template F - The type of function.\n * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @param {DebounceOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.\n * @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.\n *\n * @example\n * const debouncedFunction = debounce(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' after 1 second if not called again in that time\n * debouncedFunction();\n *\n * // Will not log anything as the previous call is canceled\n * debouncedFunction.cancel();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const signal = controller.signal;\n * const debouncedWithSignal = debounce(() => {\n * console.log('Function executed');\n * }, 1000, { signal });\n *\n * debouncedWithSignal();\n *\n * // Will cancel the debounced function call\n * controller.abort();\n */\nexport function debounce<F extends (...args: any[]) => void>(\n func: F,\n debounceMs: number,\n { signal }: DebounceOptions = {}\n): F & { cancel: () => void } {\n let timeoutId: number | null = null;\n\n const debounced = function (...args: Parameters<F>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (signal?.aborted) {\n return;\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n timeoutId = null;\n }, debounceMs) as any;\n } as F & { cancel: () => void };\n\n const onAbort = function () {\n debounced.cancel();\n };\n\n debounced.cancel = function () {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n signal?.addEventListener('abort', onAbort, { once: true });\n\n return debounced;\n}\n","/**\n * A no-operation function that does nothing.\n * This can be used as a placeholder or default function.\n *\n * @example\n * noop(); // Does nothing\n *\n * @returns {void} This function does not return anything.\n */\nexport function noop(): void {}\n","/**\n * Creates a function that is restricted to invoking the provided function `func` once.\n * Repeated calls to the function will return the value from the first invocation.\n *\n * @template F - The type of function.\n * @param {F} func - The function to restrict.\n * @returns {F} A new function that invokes `func` once and caches the result.\n *\n * @example\n * const initialize = once(() => {\n * console.log('Initialized!');\n * return true;\n * });\n *\n * initialize(); // Logs: 'Initialized!' and returns true\n * initialize(); // Returns true without logging\n */\nexport function once<F extends () => any>(func: F): F {\n let called = false;\n let cache: ReturnType<F> | undefined;\n\n return function () {\n if (called) {\n return cache;\n }\n\n const result = func();\n\n called = true;\n cache = result;\n\n return result;\n } as F;\n}\n","/**\n * Creates a throttled function that only invokes the provided function at most once\n * per every `throttleMs` milliseconds. Subsequent calls to the throttled function\n * within the wait time will not trigger the execution of the original function.\n *\n * @template F - The type of function.\n * @param {F} func - The function to throttle.\n * @param {number} throttleMs - The number of milliseconds to throttle executions to.\n * @returns {F} A new throttled function that accepts the same parameters as the original function.\n *\n * @example\n * const throttledFunction = throttle(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' immediately\n * throttledFunction();\n *\n * // Will not log anything as it is within the throttle time\n * throttledFunction();\n *\n * // After 1 second\n * setTimeout(() => {\n * throttledFunction(); // Will log 'Function executed'\n * }, 1000);\n */\nexport function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number): F {\n let lastCallTime: number | null;\n\n const throttledFunction = function (...args: Parameters<F>) {\n const now = Date.now();\n\n if (lastCallTime == null || now - lastCallTime >= throttleMs) {\n lastCallTime = now;\n func(...args);\n }\n } as F;\n\n return throttledFunction;\n}\n","/**\n * Creates a function that negates the result of the predicate function.\n *\n * @template F - The type of the function to negate.\n * @param {F} func - The function to negate.\n * @returns {F} The new negated function, which negates the boolean result of `func`.\n */\nexport function negate<F extends (...args: unknown[]) => boolean>(func: F): F {\n return ((...args: any[]) => !func(...args)) as F;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6BO,IAAM,QAAQ,CAAoC,GAAW,SAAe;AACjF,MAAI,CAAC,OAAO,UAAU,CAAC,KAAK,IAAI,GAAG;AACjC,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAEA,MAAI,UAAU;AACd,SAAQ,IAAI,SAAwB;AAClC,QAAI,EAAE,WAAW,GAAG;AAClB,aAAO,KAAK,GAAG,IAAI;AAAA,IACrB;AACA,WAAO;AAAA,EACT;AACF;;;ACFO,SAAS,SACd,MACA,YACA,EAAE,OAAO,IAAqB,CAAC,GACH;AAC5B,MAAI,YAA2B;AAE/B,QAAM,YAAY,YAAa,MAAqB;AAClD,QAAI,cAAc,MAAM;AACtB,mBAAa,SAAS;AAAA,IACxB;AAEA,QAAI,
|
|
1
|
+
{"version":3,"sources":["../../src/function/index.ts","../../src/function/after.ts","../../src/function/debounce.ts","../../src/function/noop.ts","../../src/function/once.ts","../../src/function/throttle.ts","../../src/function/negate.ts"],"sourcesContent":["export { after } from './after.ts';\nexport { debounce } from './debounce.ts';\nexport { noop } from './noop.ts';\nexport { once } from './once.ts';\nexport { throttle } from './throttle.ts';\nexport { negate } from './negate.ts';\n","/**\n * Creates a function that only executes starting from the `n`-th call.\n * The provided function will be invoked starting from the `n`-th call.\n *\n * This is particularly useful for scenarios involving events or asynchronous operations\n * where an action should occur only after a certain number of invocations.\n *\n * @template F - The type of the function to be invoked.\n * @param {number} n - The number of calls required for `func` to execute.\n * @param {F} func - The function to be invoked.\n * @returns {F} - A new function that:\n * - Tracks the number of calls.\n * - Invokes `func` starting from the `n`-th call.\n * - Returns `undefined` if fewer than `n` calls have been made.\n * @throws {Error} - Throws an error if `n` is negative.\n * @example\n *\n * const afterFn = after(3, () => {\n * console.log(\"called\")\n * });\n *\n * // Will not log anything.\n * afterFn()\n * // Will not log anything.\n * afterFn()\n * // Will log 'called'.\n * afterFn()\n */\n\nexport const after = <F extends (...args: any[]) => any>(n: number, func: F): F => {\n if (!Number.isInteger(n) || n < 0) {\n throw new Error(`n must be a non-negative integer.`);\n }\n\n let counter = 0;\n return ((...args: Parameters<F>) => {\n if (++counter >= n) {\n return func(...args);\n }\n return undefined;\n }) as F;\n};\n","interface DebounceOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * @template F - The type of function.\n * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @param {DebounceOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.\n * @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.\n *\n * @example\n * const debouncedFunction = debounce(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' after 1 second if not called again in that time\n * debouncedFunction();\n *\n * // Will not log anything as the previous call is canceled\n * debouncedFunction.cancel();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const signal = controller.signal;\n * const debouncedWithSignal = debounce(() => {\n * console.log('Function executed');\n * }, 1000, { signal });\n *\n * debouncedWithSignal();\n *\n * // Will cancel the debounced function call\n * controller.abort();\n */\nexport function debounce<F extends (...args: any[]) => void>(\n func: F,\n debounceMs: number,\n { signal }: DebounceOptions = {}\n): F & { cancel: () => void } {\n let timeoutId: number | null = null;\n\n const debounced = function (...args: Parameters<F>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (signal?.aborted) {\n return;\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n timeoutId = null;\n }, debounceMs) as any;\n } as F & { cancel: () => void };\n\n const onAbort = function () {\n debounced.cancel();\n };\n\n debounced.cancel = function () {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n signal?.addEventListener('abort', onAbort, { once: true });\n\n return debounced;\n}\n","/**\n * A no-operation function that does nothing.\n * This can be used as a placeholder or default function.\n *\n * @example\n * noop(); // Does nothing\n *\n * @returns {void} This function does not return anything.\n */\nexport function noop(): void {}\n","/**\n * Creates a function that is restricted to invoking the provided function `func` once.\n * Repeated calls to the function will return the value from the first invocation.\n *\n * @template F - The type of function.\n * @param {F} func - The function to restrict.\n * @returns {F} A new function that invokes `func` once and caches the result.\n *\n * @example\n * const initialize = once(() => {\n * console.log('Initialized!');\n * return true;\n * });\n *\n * initialize(); // Logs: 'Initialized!' and returns true\n * initialize(); // Returns true without logging\n */\nexport function once<F extends () => any>(func: F): F {\n let called = false;\n let cache: ReturnType<F> | undefined;\n\n return function () {\n if (called) {\n return cache;\n }\n\n const result = func();\n\n called = true;\n cache = result;\n\n return result;\n } as F;\n}\n","/**\n * Creates a throttled function that only invokes the provided function at most once\n * per every `throttleMs` milliseconds. Subsequent calls to the throttled function\n * within the wait time will not trigger the execution of the original function.\n *\n * @template F - The type of function.\n * @param {F} func - The function to throttle.\n * @param {number} throttleMs - The number of milliseconds to throttle executions to.\n * @returns {F} A new throttled function that accepts the same parameters as the original function.\n *\n * @example\n * const throttledFunction = throttle(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' immediately\n * throttledFunction();\n *\n * // Will not log anything as it is within the throttle time\n * throttledFunction();\n *\n * // After 1 second\n * setTimeout(() => {\n * throttledFunction(); // Will log 'Function executed'\n * }, 1000);\n */\nexport function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number): F {\n let lastCallTime: number | null;\n\n const throttledFunction = function (...args: Parameters<F>) {\n const now = Date.now();\n\n if (lastCallTime == null || now - lastCallTime >= throttleMs) {\n lastCallTime = now;\n func(...args);\n }\n } as F;\n\n return throttledFunction;\n}\n","/**\n * Creates a function that negates the result of the predicate function.\n *\n * @template F - The type of the function to negate.\n * @param {F} func - The function to negate.\n * @returns {F} The new negated function, which negates the boolean result of `func`.\n */\nexport function negate<F extends (...args: unknown[]) => boolean>(func: F): F {\n return ((...args: any[]) => !func(...args)) as F;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6BO,IAAM,QAAQ,CAAoC,GAAW,SAAe;AACjF,MAAI,CAAC,OAAO,UAAU,CAAC,KAAK,IAAI,GAAG;AACjC,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAEA,MAAI,UAAU;AACd,SAAQ,IAAI,SAAwB;AAClC,QAAI,EAAE,WAAW,GAAG;AAClB,aAAO,KAAK,GAAG,IAAI;AAAA,IACrB;AACA,WAAO;AAAA,EACT;AACF;;;ACFO,SAAS,SACd,MACA,YACA,EAAE,OAAO,IAAqB,CAAC,GACH;AAC5B,MAAI,YAA2B;AAE/B,QAAM,YAAY,YAAa,MAAqB;AAClD,QAAI,cAAc,MAAM;AACtB,mBAAa,SAAS;AAAA,IACxB;AAEA,QAAI,QAAQ,SAAS;AACnB;AAAA,IACF;AAEA,gBAAY,WAAW,MAAM;AAC3B,WAAK,GAAG,IAAI;AACZ,kBAAY;AAAA,IACd,GAAG,UAAU;AAAA,EACf;AAEA,QAAM,UAAU,WAAY;AAC1B,cAAU,OAAO;AAAA,EACnB;AAEA,YAAU,SAAS,WAAY;AAC7B,QAAI,cAAc,MAAM;AACtB,mBAAa,SAAS;AACtB,kBAAY;AAAA,IACd;AAAA,EACF;AAEA,UAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;AAEzD,SAAO;AACT;;;AClEO,SAAS,OAAa;AAAC;;;ACQvB,SAAS,KAA0B,MAAY;AACpD,MAAI,SAAS;AACb,MAAI;AAEJ,SAAO,WAAY;AACjB,QAAI,QAAQ;AACV,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,KAAK;AAEpB,aAAS;AACT,YAAQ;AAER,WAAO;AAAA,EACT;AACF;;;ACPO,SAAS,SAA6C,MAAS,YAAuB;AAC3F,MAAI;AAEJ,QAAM,oBAAoB,YAAa,MAAqB;AAC1D,UAAM,MAAM,KAAK,IAAI;AAErB,QAAI,gBAAgB,QAAQ,MAAM,gBAAgB,YAAY;AAC5D,qBAAe;AACf,WAAK,GAAG,IAAI;AAAA,IACd;AAAA,EACF;AAEA,SAAO;AACT;;;AChCO,SAAS,OAAkD,MAAY;AAC1E,SAAQ,IAAI,SAAgB,CAAC,KAAK,GAAG,IAAI;AAC7C;","names":[]}
|
package/dist/function/index.mjs
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import "../chunk-ZA2XI3OV.mjs";
|
|
2
|
-
import {
|
|
3
|
-
throttle
|
|
4
|
-
} from "../chunk-QOJGMVVR.mjs";
|
|
5
|
-
import {
|
|
6
|
-
after
|
|
7
|
-
} from "../chunk-OGZMEWPR.mjs";
|
|
8
|
-
import {
|
|
9
|
-
debounce
|
|
10
|
-
} from "../chunk-3IP4JVLL.mjs";
|
|
11
2
|
import {
|
|
12
3
|
negate
|
|
13
4
|
} from "../chunk-BOOQBJN2.mjs";
|
|
@@ -17,7 +8,16 @@ import {
|
|
|
17
8
|
import {
|
|
18
9
|
once
|
|
19
10
|
} from "../chunk-CMBC4MXG.mjs";
|
|
20
|
-
import
|
|
11
|
+
import {
|
|
12
|
+
throttle
|
|
13
|
+
} from "../chunk-QOJGMVVR.mjs";
|
|
14
|
+
import {
|
|
15
|
+
after
|
|
16
|
+
} from "../chunk-OGZMEWPR.mjs";
|
|
17
|
+
import {
|
|
18
|
+
debounce
|
|
19
|
+
} from "../chunk-MSHSKENG.mjs";
|
|
20
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
21
21
|
export {
|
|
22
22
|
after,
|
|
23
23
|
debounce,
|
package/dist/function/negate.mjs
CHANGED
package/dist/function/noop.mjs
CHANGED
package/dist/function/once.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -85,6 +85,7 @@ export { isPlainObject } from './predicate/isPlainObject.mjs';
|
|
|
85
85
|
export { isFunction } from './predicate/isFunction.mjs';
|
|
86
86
|
export { isArrayLike } from './predicate/isArrayLike.mjs';
|
|
87
87
|
export { isTypedArray } from './predicate/isTypedArray.mjs';
|
|
88
|
+
export { isPrimitive } from './predicate/isPrimitive.mjs';
|
|
88
89
|
export { delay } from './promise/delay.mjs';
|
|
89
90
|
export { withTimeout } from './promise/withTimeout.mjs';
|
|
90
91
|
export { camelCase } from './string/camelCase.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -85,6 +85,7 @@ export { isPlainObject } from './predicate/isPlainObject.js';
|
|
|
85
85
|
export { isFunction } from './predicate/isFunction.js';
|
|
86
86
|
export { isArrayLike } from './predicate/isArrayLike.js';
|
|
87
87
|
export { isTypedArray } from './predicate/isTypedArray.js';
|
|
88
|
+
export { isPrimitive } from './predicate/isPrimitive.js';
|
|
88
89
|
export { delay } from './promise/delay.js';
|
|
89
90
|
export { withTimeout } from './promise/withTimeout.js';
|
|
90
91
|
export { camelCase } from './string/camelCase.js';
|