@ls-stack/utils 3.65.0 → 3.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (336) hide show
  1. package/dist/{arrayUtils.d.cts → arrayUtils.d.mts} +24 -23
  2. package/dist/arrayUtils.mjs +249 -0
  3. package/dist/assertions-qMxfVhSu.mjs +207 -0
  4. package/dist/{assertions.d.ts → assertions.d.mts} +4 -3
  5. package/dist/assertions.mjs +3 -0
  6. package/dist/asyncQueue.d.mts +497 -0
  7. package/dist/asyncQueue.mjs +757 -0
  8. package/dist/{awaitDebounce.d.cts → awaitDebounce.d.mts} +11 -6
  9. package/dist/awaitDebounce.mjs +54 -0
  10. package/dist/{cache.d.ts → cache.d.mts} +76 -68
  11. package/dist/cache.mjs +355 -0
  12. package/dist/castValues-DfICShCc.mjs +19 -0
  13. package/dist/{castValues.d.cts → castValues.d.mts} +3 -2
  14. package/dist/castValues.mjs +3 -0
  15. package/dist/{concurrentCalls.d.ts → concurrentCalls.d.mts} +74 -65
  16. package/dist/concurrentCalls.mjs +295 -0
  17. package/dist/consoleFmt.d.mts +55 -0
  18. package/dist/consoleFmt.mjs +63 -0
  19. package/dist/conversions-DTmwEMIu.mjs +12 -0
  20. package/dist/conversions.d.mts +4 -0
  21. package/dist/conversions.mjs +3 -0
  22. package/dist/createThrottleController.d.mts +18 -0
  23. package/dist/createThrottleController.mjs +40 -0
  24. package/dist/debounce.d.mts +47 -0
  25. package/dist/debounce.mjs +117 -0
  26. package/dist/dedent.d.mts +74 -0
  27. package/dist/dedent.mjs +80 -0
  28. package/dist/deepEqual-C7EZEixx.mjs +78 -0
  29. package/dist/{deepEqual.d.cts → deepEqual.d.mts} +3 -2
  30. package/dist/deepEqual.mjs +3 -0
  31. package/dist/{deepReplaceValues.d.cts → deepReplaceValues.d.mts} +4 -3
  32. package/dist/deepReplaceValues.mjs +61 -0
  33. package/dist/diffParser.d.mts +79 -0
  34. package/dist/diffParser.mjs +424 -0
  35. package/dist/enhancedMap.d.mts +21 -0
  36. package/dist/enhancedMap.mjs +69 -0
  37. package/dist/exhaustiveMatch.d.mts +10 -0
  38. package/dist/exhaustiveMatch.mjs +48 -0
  39. package/dist/{filterObjectOrArrayKeys.d.cts → filterObjectOrArrayKeys.d.mts} +15 -8
  40. package/dist/filterObjectOrArrayKeys.mjs +497 -0
  41. package/dist/{getAutoIncrementId.d.cts → getAutoIncrementId.d.mts} +9 -5
  42. package/dist/getAutoIncrementId.mjs +53 -0
  43. package/dist/{getCompositeKey.d.cts → getCompositeKey.d.mts} +3 -2
  44. package/dist/getCompositeKey.mjs +50 -0
  45. package/dist/{getValueStableKey.d.cts → getValueStableKey.d.mts} +5 -3
  46. package/dist/getValueStableKey.mjs +17 -0
  47. package/dist/{hash.d.cts → hash.d.mts} +3 -2
  48. package/dist/hash.mjs +28 -0
  49. package/dist/interpolate.d.mts +17 -0
  50. package/dist/interpolate.mjs +28 -0
  51. package/dist/{iteratorUtils.d.cts → iteratorUtils.d.mts} +5 -4
  52. package/dist/iteratorUtils.mjs +39 -0
  53. package/dist/keepPrevIfUnchanged.d.mts +12 -0
  54. package/dist/keepPrevIfUnchanged.mjs +9 -0
  55. package/dist/keyedMap.d.mts +76 -0
  56. package/dist/keyedMap.mjs +139 -0
  57. package/dist/keyedSet.d.mts +77 -0
  58. package/dist/keyedSet.mjs +129 -0
  59. package/dist/{levenshtein.d.cts → levenshtein.d.mts} +3 -2
  60. package/dist/levenshtein.mjs +121 -0
  61. package/dist/main.d.mts +4 -0
  62. package/dist/main.mjs +7 -0
  63. package/dist/matchPath.d.mts +50 -0
  64. package/dist/matchPath.mjs +81 -0
  65. package/dist/mathUtils-BDP1lM_z.mjs +81 -0
  66. package/dist/{mathUtils.d.cts → mathUtils.d.mts} +3 -2
  67. package/dist/mathUtils.mjs +3 -0
  68. package/dist/{mutationUtils.d.cts → mutationUtils.d.mts} +6 -5
  69. package/dist/mutationUtils.mjs +44 -0
  70. package/dist/{objUtils.d.ts → objUtils.d.mts} +8 -6
  71. package/dist/objUtils.mjs +115 -0
  72. package/dist/parallelAsyncCalls.d.mts +83 -0
  73. package/dist/parallelAsyncCalls.mjs +121 -0
  74. package/dist/partialEqual.d.mts +139 -0
  75. package/dist/partialEqual.mjs +1055 -0
  76. package/dist/promiseUtils.d.mts +9 -0
  77. package/dist/promiseUtils.mjs +17 -0
  78. package/dist/regexUtils.d.mts +18 -0
  79. package/dist/regexUtils.mjs +34 -0
  80. package/dist/{retryOnError.d.cts → retryOnError.d.mts} +38 -37
  81. package/dist/retryOnError.mjs +91 -0
  82. package/dist/{runShellCmd.d.ts → runShellCmd.d.mts} +24 -15
  83. package/dist/runShellCmd.mjs +151 -0
  84. package/dist/{safeJson.d.cts → safeJson.d.mts} +3 -2
  85. package/dist/safeJson.mjs +30 -0
  86. package/dist/{saferTyping.d.cts → saferTyping.d.mts} +4 -3
  87. package/dist/saferTyping.mjs +45 -0
  88. package/dist/serializeXML.d.mts +23 -0
  89. package/dist/serializeXML.mjs +74 -0
  90. package/dist/{shallowEqual.d.cts → shallowEqual.d.mts} +3 -2
  91. package/dist/shallowEqual.mjs +54 -0
  92. package/dist/sleep.d.mts +4 -0
  93. package/dist/sleep.mjs +7 -0
  94. package/dist/stringUtils-DjhWOiYn.mjs +113 -0
  95. package/dist/{stringUtils.d.cts → stringUtils.d.mts} +3 -2
  96. package/dist/stringUtils.mjs +3 -0
  97. package/dist/{testUtils.d.ts → testUtils.d.mts} +83 -52
  98. package/dist/testUtils.mjs +310 -0
  99. package/dist/{throttle.d.ts → throttle.d.mts} +18 -17
  100. package/dist/throttle.mjs +102 -0
  101. package/dist/time-sr2lhQRw.mjs +67 -0
  102. package/dist/{time.d.ts → time.d.mts} +8 -7
  103. package/dist/time.mjs +3 -0
  104. package/dist/{timers.d.cts → timers.d.mts} +22 -13
  105. package/dist/timers.mjs +220 -0
  106. package/dist/{tsResult.d.cts → tsResult.d.mts} +52 -48
  107. package/dist/tsResult.mjs +142 -0
  108. package/dist/typeGuards-B1mzA-Rz.mjs +128 -0
  109. package/dist/{typeGuards.d.cts → typeGuards.d.mts} +3 -2
  110. package/dist/typeGuards.mjs +3 -0
  111. package/dist/{typeUtils.d.ts → typeUtils.d.mts} +13 -34
  112. package/dist/typeUtils.mjs +1 -0
  113. package/dist/{typedStrings.d.cts → typedStrings.d.mts} +5 -4
  114. package/dist/typedStrings.mjs +131 -0
  115. package/dist/typingFnUtils-Bb8drgKF.mjs +101 -0
  116. package/dist/{typingFnUtils.d.cts → typingFnUtils.d.mts} +13 -22
  117. package/dist/typingFnUtils.mjs +3 -0
  118. package/dist/{typingTestUtils.d.cts → typingTestUtils.d.mts} +11 -15
  119. package/dist/typingTestUtils.mjs +80 -0
  120. package/dist/typingUtils.d.mts +20 -0
  121. package/dist/typingUtils.mjs +1 -0
  122. package/dist/yamlStringify.d.mts +17 -0
  123. package/dist/yamlStringify.mjs +189 -0
  124. package/package.json +65 -242
  125. package/dist/arrayUtils.cjs +0 -229
  126. package/dist/arrayUtils.d.ts +0 -171
  127. package/dist/arrayUtils.js +0 -42
  128. package/dist/assertions.cjs +0 -107
  129. package/dist/assertions.d.cts +0 -192
  130. package/dist/assertions.js +0 -25
  131. package/dist/asyncQueue.cjs +0 -672
  132. package/dist/asyncQueue.d.cts +0 -488
  133. package/dist/asyncQueue.d.ts +0 -488
  134. package/dist/asyncQueue.js +0 -631
  135. package/dist/awaitDebounce.cjs +0 -106
  136. package/dist/awaitDebounce.d.ts +0 -41
  137. package/dist/awaitDebounce.js +0 -28
  138. package/dist/cache.cjs +0 -367
  139. package/dist/cache.d.cts +0 -228
  140. package/dist/cache.js +0 -19
  141. package/dist/castValues.cjs +0 -50
  142. package/dist/castValues.d.ts +0 -4
  143. package/dist/castValues.js +0 -8
  144. package/dist/chunk-5DZT3Z5Z.js +0 -8
  145. package/dist/chunk-6FBIEPWU.js +0 -96
  146. package/dist/chunk-6FIBVC2P.js +0 -56
  147. package/dist/chunk-7CQPOM5I.js +0 -100
  148. package/dist/chunk-B6DNOZCP.js +0 -369
  149. package/dist/chunk-BM4PYVOX.js +0 -109
  150. package/dist/chunk-C2SVCIWE.js +0 -57
  151. package/dist/chunk-CCUPDGSZ.js +0 -132
  152. package/dist/chunk-DBOWTYR4.js +0 -49
  153. package/dist/chunk-DFXNVEH6.js +0 -14
  154. package/dist/chunk-DX2524CZ.js +0 -314
  155. package/dist/chunk-GMJTLFM6.js +0 -60
  156. package/dist/chunk-IATIXMCE.js +0 -20
  157. package/dist/chunk-II4R3VVX.js +0 -25
  158. package/dist/chunk-JF2MDHOJ.js +0 -40
  159. package/dist/chunk-JQFUKJU5.js +0 -71
  160. package/dist/chunk-MI4UE2PQ.js +0 -561
  161. package/dist/chunk-PUKVXYYL.js +0 -52
  162. package/dist/chunk-QQS7I7ZL.js +0 -16
  163. package/dist/chunk-VAAMRG4K.js +0 -20
  164. package/dist/chunk-WFQJUJTC.js +0 -182
  165. package/dist/chunk-ZXIKIA5B.js +0 -178
  166. package/dist/concurrentCalls.cjs +0 -406
  167. package/dist/concurrentCalls.d.cts +0 -116
  168. package/dist/concurrentCalls.js +0 -346
  169. package/dist/consoleFmt.cjs +0 -85
  170. package/dist/consoleFmt.d.cts +0 -54
  171. package/dist/consoleFmt.d.ts +0 -54
  172. package/dist/consoleFmt.js +0 -60
  173. package/dist/conversions.cjs +0 -44
  174. package/dist/conversions.d.cts +0 -3
  175. package/dist/conversions.d.ts +0 -3
  176. package/dist/conversions.js +0 -6
  177. package/dist/createThrottleController.cjs +0 -193
  178. package/dist/createThrottleController.d.cts +0 -13
  179. package/dist/createThrottleController.d.ts +0 -13
  180. package/dist/createThrottleController.js +0 -61
  181. package/dist/debounce.cjs +0 -157
  182. package/dist/debounce.d.cts +0 -46
  183. package/dist/debounce.d.ts +0 -46
  184. package/dist/debounce.js +0 -8
  185. package/dist/dedent.cjs +0 -104
  186. package/dist/dedent.d.cts +0 -73
  187. package/dist/dedent.d.ts +0 -73
  188. package/dist/dedent.js +0 -79
  189. package/dist/deepEqual.cjs +0 -96
  190. package/dist/deepEqual.d.ts +0 -21
  191. package/dist/deepEqual.js +0 -8
  192. package/dist/deepReplaceValues.cjs +0 -87
  193. package/dist/deepReplaceValues.d.ts +0 -27
  194. package/dist/deepReplaceValues.js +0 -7
  195. package/dist/enhancedMap.cjs +0 -131
  196. package/dist/enhancedMap.d.cts +0 -20
  197. package/dist/enhancedMap.d.ts +0 -20
  198. package/dist/enhancedMap.js +0 -10
  199. package/dist/exhaustiveMatch.cjs +0 -66
  200. package/dist/exhaustiveMatch.d.cts +0 -9
  201. package/dist/exhaustiveMatch.d.ts +0 -9
  202. package/dist/exhaustiveMatch.js +0 -40
  203. package/dist/filterObjectOrArrayKeys.cjs +0 -619
  204. package/dist/filterObjectOrArrayKeys.d.ts +0 -88
  205. package/dist/filterObjectOrArrayKeys.js +0 -9
  206. package/dist/getAutoIncrementId.cjs +0 -44
  207. package/dist/getAutoIncrementId.d.ts +0 -46
  208. package/dist/getAutoIncrementId.js +0 -18
  209. package/dist/getCompositeKey.cjs +0 -86
  210. package/dist/getCompositeKey.d.ts +0 -11
  211. package/dist/getCompositeKey.js +0 -8
  212. package/dist/getValueStableKey.cjs +0 -89
  213. package/dist/getValueStableKey.d.ts +0 -15
  214. package/dist/getValueStableKey.js +0 -11
  215. package/dist/hash.cjs +0 -57
  216. package/dist/hash.d.ts +0 -7
  217. package/dist/hash.js +0 -32
  218. package/dist/interpolate.cjs +0 -88
  219. package/dist/interpolate.d.cts +0 -11
  220. package/dist/interpolate.d.ts +0 -11
  221. package/dist/interpolate.js +0 -46
  222. package/dist/iteratorUtils.cjs +0 -73
  223. package/dist/iteratorUtils.d.ts +0 -10
  224. package/dist/iteratorUtils.js +0 -44
  225. package/dist/keepPrevIfUnchanged.cjs +0 -102
  226. package/dist/keepPrevIfUnchanged.d.cts +0 -7
  227. package/dist/keepPrevIfUnchanged.d.ts +0 -7
  228. package/dist/keepPrevIfUnchanged.js +0 -7
  229. package/dist/keyedMap.cjs +0 -224
  230. package/dist/keyedMap.d.cts +0 -75
  231. package/dist/keyedMap.d.ts +0 -75
  232. package/dist/keyedMap.js +0 -145
  233. package/dist/keyedSet.cjs +0 -205
  234. package/dist/keyedSet.d.cts +0 -76
  235. package/dist/keyedSet.d.ts +0 -76
  236. package/dist/keyedSet.js +0 -126
  237. package/dist/levenshtein.cjs +0 -180
  238. package/dist/levenshtein.d.ts +0 -5
  239. package/dist/levenshtein.js +0 -153
  240. package/dist/main.cjs +0 -32
  241. package/dist/main.d.cts +0 -3
  242. package/dist/main.d.ts +0 -3
  243. package/dist/main.js +0 -7
  244. package/dist/matchPath.cjs +0 -155
  245. package/dist/matchPath.d.cts +0 -53
  246. package/dist/matchPath.d.ts +0 -53
  247. package/dist/matchPath.js +0 -108
  248. package/dist/mathUtils.cjs +0 -81
  249. package/dist/mathUtils.d.ts +0 -54
  250. package/dist/mathUtils.js +0 -22
  251. package/dist/mutationUtils.cjs +0 -153
  252. package/dist/mutationUtils.d.ts +0 -15
  253. package/dist/mutationUtils.js +0 -55
  254. package/dist/objUtils.cjs +0 -242
  255. package/dist/objUtils.d.cts +0 -28
  256. package/dist/objUtils.js +0 -38
  257. package/dist/parallelAsyncCalls.cjs +0 -162
  258. package/dist/parallelAsyncCalls.d.cts +0 -82
  259. package/dist/parallelAsyncCalls.d.ts +0 -82
  260. package/dist/parallelAsyncCalls.js +0 -126
  261. package/dist/partialEqual.cjs +0 -1196
  262. package/dist/partialEqual.d.cts +0 -141
  263. package/dist/partialEqual.d.ts +0 -141
  264. package/dist/partialEqual.js +0 -1168
  265. package/dist/promiseUtils.cjs +0 -38
  266. package/dist/promiseUtils.d.cts +0 -8
  267. package/dist/promiseUtils.d.ts +0 -8
  268. package/dist/promiseUtils.js +0 -6
  269. package/dist/regexUtils.cjs +0 -60
  270. package/dist/regexUtils.d.cts +0 -17
  271. package/dist/regexUtils.d.ts +0 -17
  272. package/dist/regexUtils.js +0 -33
  273. package/dist/retryOnError.cjs +0 -130
  274. package/dist/retryOnError.d.ts +0 -83
  275. package/dist/retryOnError.js +0 -101
  276. package/dist/runShellCmd.cjs +0 -127
  277. package/dist/runShellCmd.d.cts +0 -90
  278. package/dist/runShellCmd.js +0 -98
  279. package/dist/safeJson.cjs +0 -45
  280. package/dist/safeJson.d.ts +0 -16
  281. package/dist/safeJson.js +0 -8
  282. package/dist/saferTyping.cjs +0 -52
  283. package/dist/saferTyping.d.ts +0 -47
  284. package/dist/saferTyping.js +0 -23
  285. package/dist/serializeXML.cjs +0 -154
  286. package/dist/serializeXML.d.cts +0 -22
  287. package/dist/serializeXML.d.ts +0 -22
  288. package/dist/serializeXML.js +0 -116
  289. package/dist/shallowEqual.cjs +0 -88
  290. package/dist/shallowEqual.d.ts +0 -4
  291. package/dist/shallowEqual.js +0 -63
  292. package/dist/sleep.cjs +0 -32
  293. package/dist/sleep.d.cts +0 -3
  294. package/dist/sleep.d.ts +0 -3
  295. package/dist/sleep.js +0 -6
  296. package/dist/stringUtils.cjs +0 -155
  297. package/dist/stringUtils.d.ts +0 -55
  298. package/dist/stringUtils.js +0 -50
  299. package/dist/testUtils.cjs +0 -1490
  300. package/dist/testUtils.d.cts +0 -133
  301. package/dist/testUtils.js +0 -359
  302. package/dist/throttle.cjs +0 -282
  303. package/dist/throttle.d.cts +0 -98
  304. package/dist/throttle.js +0 -38
  305. package/dist/time.cjs +0 -152
  306. package/dist/time.d.cts +0 -25
  307. package/dist/time.js +0 -38
  308. package/dist/timers.cjs +0 -194
  309. package/dist/timers.d.ts +0 -121
  310. package/dist/timers.js +0 -156
  311. package/dist/tsResult.cjs +0 -226
  312. package/dist/tsResult.d.ts +0 -114
  313. package/dist/tsResult.js +0 -180
  314. package/dist/typeGuards.cjs +0 -70
  315. package/dist/typeGuards.d.ts +0 -111
  316. package/dist/typeGuards.js +0 -18
  317. package/dist/typeUtils.cjs +0 -18
  318. package/dist/typeUtils.d.cts +0 -61
  319. package/dist/typeUtils.js +0 -0
  320. package/dist/typedStrings.cjs +0 -90
  321. package/dist/typedStrings.d.ts +0 -163
  322. package/dist/typedStrings.js +0 -57
  323. package/dist/typingFnUtils.cjs +0 -96
  324. package/dist/typingFnUtils.d.ts +0 -100
  325. package/dist/typingFnUtils.js +0 -30
  326. package/dist/typingTestUtils.cjs +0 -52
  327. package/dist/typingTestUtils.d.ts +0 -79
  328. package/dist/typingTestUtils.js +0 -27
  329. package/dist/typingUtils.cjs +0 -18
  330. package/dist/typingUtils.d.cts +0 -35
  331. package/dist/typingUtils.d.ts +0 -35
  332. package/dist/typingUtils.js +0 -0
  333. package/dist/yamlStringify.cjs +0 -423
  334. package/dist/yamlStringify.d.cts +0 -10
  335. package/dist/yamlStringify.d.ts +0 -10
  336. package/dist/yamlStringify.js +0 -9
@@ -0,0 +1,310 @@
1
+ import { a as isPlainObject } from "./typeGuards-B1mzA-Rz.mjs";
2
+ import { o as isObject } from "./assertions-qMxfVhSu.mjs";
3
+ import { arrayWithPrevAndIndex, filterAndMap } from "./arrayUtils.mjs";
4
+ import { defer } from "./promiseUtils.mjs";
5
+ import { i as clampMin } from "./mathUtils-BDP1lM_z.mjs";
6
+ import { t as deepEqual } from "./deepEqual-C7EZEixx.mjs";
7
+ import { deepReplaceValues } from "./deepReplaceValues.mjs";
8
+ import { filterObjectOrArrayKeys } from "./filterObjectOrArrayKeys.mjs";
9
+ import { omit, pick } from "./objUtils.mjs";
10
+ import { yamlStringify } from "./yamlStringify.mjs";
11
+
12
+ //#region src/testUtils.ts
13
+ function createLoggerStore({ filterKeys: defaultFilterKeys, rejectKeys: defaultRejectKeys, splitLongLines: defaultSplitLongLines = true, maxLineLengthBeforeSplit: defaultMaxLineLengthBeforeSplit = 80, fromLastSnapshot: defaultFromLastSnapshot = false, arrays: defaultArrays = { firstNItems: 1 }, changesOnly: defaultChangesOnly = false, useEmojiForBooleans: defaultUseEmojiForBooleans = true } = {}) {
14
+ let logs = [];
15
+ let logsTime = [];
16
+ let startTime = Date.now();
17
+ let onNextLog = () => {};
18
+ function reset(keepLastRender = false) {
19
+ logs = keepLastRender ? [logs.at(-1)] : [];
20
+ logsTime = [];
21
+ startTime = Date.now();
22
+ }
23
+ function add(render) {
24
+ if (!isObject(render)) for (const [i, r] of render.entries()) {
25
+ logs.push({
26
+ i: i + 1,
27
+ ...r
28
+ });
29
+ logsTime.push(Date.now() - startTime);
30
+ }
31
+ else {
32
+ logs.push(render);
33
+ logsTime.push(Date.now() - startTime);
34
+ }
35
+ onNextLog();
36
+ if (logs.length > 100) throw new Error("Too many logs");
37
+ }
38
+ function logsCount() {
39
+ return logs.filter((item) => !item._lastSnapshotMark).length;
40
+ }
41
+ async function waitNextLog(timeout = 50) {
42
+ return new Promise((resolve) => {
43
+ const timeoutId = setTimeout(() => {
44
+ throw new Error("Timeout");
45
+ }, timeout);
46
+ onNextLog = () => {
47
+ clearTimeout(timeoutId);
48
+ resolve();
49
+ };
50
+ });
51
+ }
52
+ function getSnapshot({ arrays = defaultArrays, changesOnly = defaultChangesOnly, filterKeys = defaultFilterKeys, rejectKeys = defaultRejectKeys, includeLastSnapshotEndMark = true, splitLongLines = defaultSplitLongLines, maxLineLengthBeforeSplit = defaultMaxLineLengthBeforeSplit, fromLastSnapshot = defaultFromLastSnapshot, useEmojiForBooleans = defaultUseEmojiForBooleans } = {}) {
53
+ let rendersToUse = logs;
54
+ if (changesOnly || filterKeys || rejectKeys) {
55
+ rendersToUse = [];
56
+ for (let { item, prev } of arrayWithPrevAndIndex(logs)) {
57
+ if (item._lastSnapshotMark || item._mark) {
58
+ rendersToUse.push(item);
59
+ continue;
60
+ }
61
+ if (filterKeys) {
62
+ prev = prev && pick(prev, filterKeys);
63
+ item = pick(item, filterKeys);
64
+ }
65
+ if (rejectKeys) {
66
+ prev = prev && omit(prev, rejectKeys);
67
+ item = omit(item, rejectKeys);
68
+ }
69
+ if (!deepEqual(prev, item)) rendersToUse.push(item);
70
+ }
71
+ }
72
+ if (fromLastSnapshot) {
73
+ const lastSnapshotMark = rendersToUse.findLastIndex((item) => item._lastSnapshotMark === true);
74
+ rendersToUse = rendersToUse.slice(clampMin(lastSnapshotMark, 0));
75
+ }
76
+ logs.push({ _lastSnapshotMark: true });
77
+ const propDivider = "⋅";
78
+ const snapShot = `\n${filterAndMap(rendersToUse, (render, i) => {
79
+ if (render._lastSnapshotMark) if (includeLastSnapshotEndMark) {
80
+ if (rendersToUse.length === 1) return "⋅⋅⋅";
81
+ if (i !== rendersToUse.length - 1) return "⋅⋅⋅";
82
+ return false;
83
+ } else return false;
84
+ if (render._mark) {
85
+ let mark = `${rendersToUse[i - 1]?._lastSnapshotMark ? "" : "\n"}>>> ${String(render._mark)}`;
86
+ const nextRender = rendersToUse[i + 1];
87
+ if (nextRender && !nextRender._mark && !nextRender._lastSnapshotMark) mark = `${mark}\n`;
88
+ return mark;
89
+ }
90
+ let line = "";
91
+ for (const [key, _value] of Object.entries(render)) {
92
+ let value = _value;
93
+ if (Array.isArray(value)) {
94
+ if (arrays === "length") value = `Array(${value.length})`;
95
+ else if (arrays === "firstAndLast" && value.length > 2) {
96
+ const intermediateSize = clampMin(value.length - 2, 0);
97
+ value = [
98
+ value[0],
99
+ `…(${intermediateSize} between)`,
100
+ value.at(-1)
101
+ ];
102
+ } else if (typeof arrays === "object" && value.length > 2) value = [...value.slice(0, arrays.firstNItems), `…(${value.length - arrays.firstNItems} more)`];
103
+ }
104
+ if (typeof value === "boolean" && useEmojiForBooleans) value = value ? "✅" : "❌";
105
+ if (value === "") value = `''`;
106
+ if (typeof value === "object" && value !== null) value = JSON.stringify(value).replace(/:true/g, ":✅").replace(/:false/g, ":❌").replace(/:""/g, ":''").replace(/"/g, "").replace(/,/g, ", ");
107
+ line += `${key}: ${value} ${propDivider} `;
108
+ }
109
+ line = line.slice(0, -3);
110
+ if (splitLongLines && line.length > maxLineLengthBeforeSplit) {
111
+ const parts = line.split(` ${propDivider} `);
112
+ if (parts.length === 1) return line;
113
+ line = "";
114
+ const propDividerML = "⋅";
115
+ for (const { item, index } of arrayWithPrevAndIndex(parts)) {
116
+ if (index === 0) line += `┌─\n${propDividerML} `;
117
+ else if (index === parts.length - 1) line += `${propDividerML} `;
118
+ else line += `${propDividerML} `;
119
+ line += `${item}\n`;
120
+ if (index === parts.length - 1) line += "└─";
121
+ }
122
+ } else line = `-> ${line}`;
123
+ return line;
124
+ }).join("\n")}\n`;
125
+ return snapShot === `\n⋅⋅⋅\n` ? "⋅⋅⋅empty⋅⋅⋅" : snapShot;
126
+ }
127
+ function addMark(label) {
128
+ add({ _mark: label });
129
+ }
130
+ return {
131
+ add,
132
+ reset,
133
+ getSnapshot,
134
+ waitNextLog,
135
+ get changesSnapshot() {
136
+ return getSnapshot({ changesOnly: true });
137
+ },
138
+ get snapshot() {
139
+ return getSnapshot();
140
+ },
141
+ get snapshotFromLast() {
142
+ return getSnapshot({ fromLastSnapshot: true });
143
+ },
144
+ logsCount,
145
+ get rendersTime() {
146
+ return logsTime;
147
+ },
148
+ addMark
149
+ };
150
+ }
151
+ function getResultFn(fnGetter, wrapper) {
152
+ return ((...args) => {
153
+ const fn = fnGetter();
154
+ if (wrapper) return wrapper(fn(...args));
155
+ else return fn(...args);
156
+ });
157
+ }
158
+ function waitController() {
159
+ const { promise, resolve } = defer();
160
+ return {
161
+ wait: promise,
162
+ stopWaiting: () => {
163
+ resolve();
164
+ },
165
+ stopWaitingAfter: (ms) => {
166
+ setTimeout(() => {
167
+ resolve();
168
+ }, ms);
169
+ }
170
+ };
171
+ }
172
+ /**
173
+ * Produces a more compact and readable snapshot of a value using yaml. By
174
+ * default booleans are shown as `✅` and `❌`, use `showBooleansAs` to
175
+ * disable/configure this.
176
+ *
177
+ * Filtering patterns in `rejectKeys` and `filterKeys`:
178
+ *
179
+ * - `'prop'` - Only root-level properties named 'prop'
180
+ * - `'**prop'` - Any property named exactly 'prop' at any level (root or nested)
181
+ * - `'*.prop'` - Any nested property named 'prop' at second level (excludes
182
+ * root-level matches)
183
+ * - `'test.*.prop'` - Any property named 'prop' at second level of 'test'
184
+ * - `'test.*.test.**prop'` - Any property named 'prop' inside of 'test.*.test'
185
+ * - `'prop.nested'` - Exact nested property paths like `obj.prop.nested`
186
+ * - `'prop.**nested'` - All nested properties inside root `prop` with name
187
+ * `nested`
188
+ * - `'prop[0]'` - The first item of the `prop` array
189
+ * - `'prop[*]'` - All items of the `prop` array
190
+ * - `'prop[0].nested'` - `nested` prop of the first item of the `prop` array
191
+ * - `'prop[*].nested'` - `nested` prop of all items of the `prop` array
192
+ * - `'prop[*]**nested'` - all `nested` props of all items of the `prop` array
193
+ * - `'prop[0-2]'` - The first three items of the `prop` array
194
+ * - `'prop[4-*]'` - All items of the `prop` array from the fourth index to the
195
+ * end
196
+ * - `'prop[0-2].nested.**prop'` - Combining multiple nested patterns is supported
197
+ * - Root array:
198
+ *
199
+ * - `'[0]'` - The first item of the root array
200
+ * - `'[*]'` - All items of the array
201
+ * - `'[0].nested'` - `nested` prop of the first item of the array
202
+ * - `'[*].nested'` - `nested` prop of all items of the array
203
+ * - `'[*]**nested'` - all `nested` props of all items of the array
204
+ * - `'[0-2]'` - The first three items of the array
205
+ * - `'[4-*]'` - All items of the array from the fourth index to the end
206
+ * - Expanding the patterns with parentheses:
207
+ *
208
+ * - `'prop.test.(prop1|prop2|prop3.prop4)'` - Will produce `prop.test.prop1`,
209
+ * `prop.test.prop2`, and `prop.test.prop3.prop4`
210
+ * - Array filtering by value:
211
+ *
212
+ * - `'users[%name="John"]'` - Filters the `users` with the `name` property equal
213
+ * to `John`
214
+ * - `'users[%name="John" | "Jane"]'` - Filters the `users` with the `name`
215
+ * property equal to `John` or `Jane`
216
+ * - `'users[%name="John" | "Jane" && %age=20]'` - AND and OR are supported by
217
+ * using `&&` and `||`, nesting logical operators is not supported yet
218
+ * - `'users[%config.name="John" | "Jane"]'` - Dot notation is supported
219
+ *
220
+ * Check more supported patterns in {@link filterObjectOrArrayKeys} docs.
221
+ *
222
+ * @param value - The value to snapshot.
223
+ * @param options - The options for the snapshot.
224
+ * @param options.collapseObjects - Whether to collapse objects into a single
225
+ * line.
226
+ * @param options.maxLineLength - The maximum length of a line.
227
+ * @param options.showUndefined - Whether to show undefined values.
228
+ * @param options.showBooleansAs - Whether to show booleans as text, by default
229
+ * true is `✅` and false is `❌`
230
+ * @param options.rejectKeys - The keys to reject.
231
+ * @param options.filterKeys - The keys to filter.
232
+ * @param options.ignoreProps - The props to ignore.
233
+ * @param options.replaceValues - Function to replace values at specific paths.
234
+ * Returns `false` to keep original value or `{newValue}` to replace.
235
+ * @param options.sortKeys - Sort all keys by a specific order (default:
236
+ * `simpleValuesFirst`).
237
+ * @param options.sortPatterns - Sort specific keys by pattern. Use to control
238
+ * the order of specific properties. The same patterns as `filterKeys` are
239
+ * supported.
240
+ * @returns The compact snapshot of the value.
241
+ */
242
+ function compactSnapshot(value, { collapseObjects = true, maxLineLength = 100, showUndefined = false, showBooleansAs = true, replaceValues, rejectKeys, filterKeys, sortKeys, sortPatterns, ...options } = {}) {
243
+ let processedValue = value;
244
+ if (rejectKeys || filterKeys) {
245
+ if (isPlainObject(processedValue) || Array.isArray(processedValue)) processedValue = filterObjectOrArrayKeys(processedValue, {
246
+ rejectKeys,
247
+ filterKeys,
248
+ sortKeys,
249
+ sortPatterns
250
+ });
251
+ }
252
+ if (replaceValues) processedValue = deepReplaceValues(processedValue, replaceValues);
253
+ processedValue = showBooleansAs ? replaceBooleansWithEmoji(processedValue, showBooleansAs) : processedValue;
254
+ return `\n${yamlStringify(processedValue, {
255
+ collapseObjects,
256
+ maxLineLength,
257
+ showUndefined,
258
+ ...options
259
+ })}`;
260
+ }
261
+ function replaceBooleansWithEmoji(value, showBooleansAs, visited = /* @__PURE__ */ new Set()) {
262
+ if (showBooleansAs === false) return value;
263
+ const defaultTrueText = "✅";
264
+ const defaultFalseText = "❌";
265
+ const config = typeof showBooleansAs === "boolean" ? {
266
+ trueText: defaultTrueText,
267
+ falseText: defaultFalseText
268
+ } : {
269
+ trueText: showBooleansAs.trueText ?? defaultTrueText,
270
+ falseText: showBooleansAs.falseText ?? defaultFalseText,
271
+ props: showBooleansAs.props ?? {},
272
+ ignoreProps: showBooleansAs.ignoreProps ?? []
273
+ };
274
+ function processValue(val, propName) {
275
+ if (typeof val === "boolean") {
276
+ if (propName && config.ignoreProps?.includes(propName)) return val;
277
+ if (propName && config.props?.[propName]) {
278
+ const propConfig = config.props[propName];
279
+ if (propConfig === true) return val ? config.trueText : config.falseText;
280
+ return val ? propConfig.trueText ?? config.trueText : propConfig.falseText ?? config.falseText;
281
+ }
282
+ return val ? config.trueText : config.falseText;
283
+ }
284
+ if (Array.isArray(val)) {
285
+ if (visited.has(val)) throw new Error("Circular reference detected in array");
286
+ visited.add(val);
287
+ try {
288
+ return val.map((item) => processValue(item));
289
+ } finally {
290
+ visited.delete(val);
291
+ }
292
+ }
293
+ if (isPlainObject(val)) {
294
+ if (visited.has(val)) throw new Error("Circular reference detected in object");
295
+ visited.add(val);
296
+ try {
297
+ const result = {};
298
+ for (const [key, itemValue] of Object.entries(val)) result[key] = processValue(itemValue, key);
299
+ return result;
300
+ } finally {
301
+ visited.delete(val);
302
+ }
303
+ }
304
+ return val;
305
+ }
306
+ return processValue(value);
307
+ }
308
+
309
+ //#endregion
310
+ export { compactSnapshot, createLoggerStore, getResultFn, waitController };
@@ -1,19 +1,20 @@
1
- import { DebouncedFunc } from './debounce.js';
2
- import { __LEGIT_ANY_FUNCTION__ } from './saferTyping.js';
1
+ import { __LEGIT_ANY_FUNCTION__ } from "./saferTyping.mjs";
2
+ import { DebouncedFunc } from "./debounce.mjs";
3
3
 
4
+ //#region src/throttle.d.ts
4
5
  interface ThrottleSettings {
5
- /**
6
- * Specify invoking on the leading edge of the timeout.
7
- *
8
- * @default true
9
- */
10
- leading?: boolean;
11
- /**
12
- * Specify invoking on the trailing edge of the timeout.
13
- *
14
- * @default true
15
- */
16
- trailing?: boolean;
6
+ /**
7
+ * Specify invoking on the leading edge of the timeout.
8
+ *
9
+ * @default true
10
+ */
11
+ leading?: boolean;
12
+ /**
13
+ * Specify invoking on the trailing edge of the timeout.
14
+ *
15
+ * @default true
16
+ */
17
+ trailing?: boolean;
17
18
  }
18
19
  /**
19
20
  * Creates a throttled function that only invokes the provided function at most
@@ -92,7 +93,7 @@ declare function throttle<T extends __LEGIT_ANY_FUNCTION__>(func: T, wait: numbe
92
93
  * @returns An object with a `call` method that accepts the callback arguments
93
94
  */
94
95
  declare function createThrottledFunctionFactory<T extends string | number | null | undefined | boolean, R>(wait: number, callback: (...args: T[]) => R, options?: ThrottleSettings): {
95
- call: (...args: T[]) => R | undefined;
96
+ call: (...args: T[]) => R | undefined;
96
97
  };
97
-
98
- export { createThrottledFunctionFactory, throttle };
98
+ //#endregion
99
+ export { createThrottledFunctionFactory, throttle };
@@ -0,0 +1,102 @@
1
+ import { EnhancedMap } from "./enhancedMap.mjs";
2
+ import { debounce } from "./debounce.mjs";
3
+
4
+ //#region src/throttle.ts
5
+ /**
6
+ * Creates a throttled function that only invokes the provided function at most
7
+ * once per every `wait` milliseconds. The throttled function comes with a
8
+ * `cancel` method to cancel delayed invocations and a `flush` method to
9
+ * immediately invoke them.
10
+ *
11
+ * Throttling is useful for rate-limiting events that fire frequently, like
12
+ * scroll or resize handlers. Unlike debouncing, throttling guarantees the
13
+ * function is called at regular intervals.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const throttledSave = throttle(saveData, 1000);
18
+ *
19
+ * // Will only call saveData at most once per second
20
+ * throttledSave();
21
+ * throttledSave();
22
+ * throttledSave();
23
+ * ```;
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * // Only invoke on trailing edge
28
+ * const throttledHandler = throttle(handleScroll, 100, { leading: false });
29
+ * ```;
30
+ *
31
+ * @template T - The type of the function to throttle
32
+ * @param func - The function to throttle
33
+ * @param wait - The number of milliseconds to throttle invocations to
34
+ * @param options - The options object
35
+ * @param options.leading - Specify invoking on the leading edge of the timeout
36
+ * (default: true)
37
+ * @param options.trailing - Specify invoking on the trailing edge of the
38
+ * timeout (default: true)
39
+ * @returns Returns the new throttled function
40
+ */
41
+ function throttle(func, wait, options) {
42
+ let leading = true;
43
+ let trailing = true;
44
+ if (options) {
45
+ leading = "leading" in options ? !!options.leading : leading;
46
+ trailing = "trailing" in options ? !!options.trailing : trailing;
47
+ }
48
+ return debounce(func, wait, {
49
+ leading,
50
+ maxWait: wait,
51
+ trailing
52
+ });
53
+ }
54
+ /**
55
+ * Creates a factory for throttled functions that caches throttled instances
56
+ * based on function arguments. Each unique set of arguments gets its own
57
+ * throttled function instance, allowing for fine-grained throttling control per
58
+ * argument combination.
59
+ *
60
+ * This is useful when you want to throttle calls to the same function but with
61
+ * different parameters independently. For example, throttling API calls per
62
+ * user ID or throttling UI updates per component.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const apiThrottle = createThrottledFunctionFactory(
67
+ * 1000,
68
+ * (userId: string, action: string) => callAPI(userId, action)
69
+ * );
70
+ *
71
+ * // Each user gets their own throttled instance
72
+ * apiThrottle.call('user1', 'update'); // Executes immediately
73
+ * apiThrottle.call('user2', 'update'); // Executes immediately (different user)
74
+ * apiThrottle.call('user1', 'update'); // Throttled (same user)
75
+ * ```;
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * // Throttle UI updates per component
80
+ * const updateThrottle = createThrottledFunctionFactory(
81
+ * 100,
82
+ * (componentId: string, data: any) => updateComponent(componentId, data)
83
+ * );
84
+ * ```;
85
+ *
86
+ * @template T - The type of arguments the callback function accepts
87
+ * @template R - The return type of the callback function
88
+ * @param wait - The number of milliseconds to throttle invocations to
89
+ * @param callback - The function to throttle
90
+ * @param options - The throttle options (leading/trailing behavior)
91
+ * @returns An object with a `call` method that accepts the callback arguments
92
+ */
93
+ function createThrottledFunctionFactory(wait, callback, options) {
94
+ const cache = new EnhancedMap();
95
+ return { call: (...args) => {
96
+ const key = args.map((arg) => arg === void 0 ? "__UNDEFINED__" : JSON.stringify(arg)).join(",");
97
+ return cache.getOrInsert(key, () => throttle(callback, wait, options))(...args);
98
+ } };
99
+ }
100
+
101
+ //#endregion
102
+ export { createThrottledFunctionFactory, throttle };
@@ -0,0 +1,67 @@
1
+ import { t as castToNumber } from "./castValues-DfICShCc.mjs";
2
+ import { r as clampMax } from "./mathUtils-BDP1lM_z.mjs";
3
+
4
+ //#region src/time.ts
5
+ const MINUTE_AS_MS = 60 * 1e3;
6
+ const HOUR_AS_MS = 60 * MINUTE_AS_MS;
7
+ const DAY_AS_MS = 24 * HOUR_AS_MS;
8
+ const WEEK_AS_MS = 7 * DAY_AS_MS;
9
+ const MONTH_AS_MS = 30 * DAY_AS_MS;
10
+ const YEAR_AS_MS = 365 * DAY_AS_MS;
11
+ const HOUR_AS_SECS = 3600;
12
+ const DAY_AS_SECS = 24 * HOUR_AS_SECS;
13
+ const WEEK_AS_SECS = 7 * DAY_AS_SECS;
14
+ const MONTH_AS_SECS = 30 * DAY_AS_SECS;
15
+ const YEAR_AS_SECS = 365 * DAY_AS_SECS;
16
+ function dateStringOrNullToUnixMs(isoString) {
17
+ if (!isoString) return null;
18
+ const unixMs = new Date(isoString).getTime();
19
+ if (isNaN(unixMs)) return null;
20
+ return unixMs;
21
+ }
22
+ function msToTimeString(ms, format, hoursMinLength = 2) {
23
+ const { hours, minutes, seconds, milliseconds } = msToDurationObj(ms);
24
+ const hoursString = padTimeVal(hours, hoursMinLength);
25
+ const minutesString = padTimeVal(minutes);
26
+ if (format === "minutes") return `${hoursString}:${minutesString}`;
27
+ const secondsString = padTimeVal(seconds);
28
+ if (format === "seconds") return `${hoursString}:${minutesString}:${secondsString}`;
29
+ return `${hoursString}:${minutesString}:${secondsString}:${padTimeVal(milliseconds, 3)}`;
30
+ }
31
+ function padTimeVal(val, maxLength = 2) {
32
+ return val.toString().padStart(maxLength, "0");
33
+ }
34
+ function parseTimeStringToMs(timeString) {
35
+ if (!timeString.trim()) return 0;
36
+ const [hours, minutes, seconds, ms] = timeString.split(":");
37
+ return getTimeStringPartToInt(hours) * HOUR_AS_MS + clampMax(getTimeStringPartToInt(minutes), 59) * MINUTE_AS_MS + clampMax(getTimeStringPartToInt(seconds), 59) * 1e3 + getTimeStringPartToInt(ms, 3);
38
+ }
39
+ function getTimeStringPartToInt(timeStringPart, length) {
40
+ if (!timeStringPart?.trim()) return 0;
41
+ let string = timeStringPart.replaceAll("_", "0");
42
+ string = string.replaceAll("-", "");
43
+ if (length) {
44
+ string = string.padEnd(length, "0");
45
+ if (string.length > length) string = string.slice(0, length);
46
+ }
47
+ const num = castToNumber(string);
48
+ if (!num) return 0;
49
+ return Math.floor(num);
50
+ }
51
+ function msToDurationObj(ms) {
52
+ return {
53
+ milliseconds: ms % 1e3,
54
+ seconds: Math.floor(ms / 1e3) % 60,
55
+ minutes: Math.floor(ms / 1e3 / 60) % 60,
56
+ hours: Math.floor(ms / 1e3 / 60 / 60)
57
+ };
58
+ }
59
+ function getUnixSeconds() {
60
+ return Math.floor(Date.now() / 1e3);
61
+ }
62
+ function durationObjToMs(durationObj) {
63
+ return (durationObj.hours ?? 0) * HOUR_AS_MS + (durationObj.minutes ?? 0) * MINUTE_AS_MS + (durationObj.seconds ?? 0) * 1e3 + (durationObj.ms ?? 0) + (durationObj.days ?? 0) * DAY_AS_MS;
64
+ }
65
+
66
+ //#endregion
67
+ export { MINUTE_AS_MS as a, WEEK_AS_MS as c, YEAR_AS_SECS as d, dateStringOrNullToUnixMs as f, parseTimeStringToMs as g, msToTimeString as h, HOUR_AS_SECS as i, WEEK_AS_SECS as l, getUnixSeconds as m, DAY_AS_SECS as n, MONTH_AS_MS as o, durationObjToMs as p, HOUR_AS_MS as r, MONTH_AS_SECS as s, DAY_AS_MS as t, YEAR_AS_MS as u };
@@ -1,3 +1,4 @@
1
+ //#region src/time.d.ts
1
2
  declare const MINUTE_AS_MS: number;
2
3
  declare const HOUR_AS_MS: number;
3
4
  declare const DAY_AS_MS: number;
@@ -14,12 +15,12 @@ declare function msToTimeString(ms: number, format: 'minutes' | 'seconds' | 'mil
14
15
  declare function parseTimeStringToMs(timeString: string): number;
15
16
  declare function getUnixSeconds(): number;
16
17
  type DurationObj = {
17
- ms?: number;
18
- seconds?: number;
19
- minutes?: number;
20
- hours?: number;
21
- days?: number;
18
+ ms?: number;
19
+ seconds?: number;
20
+ minutes?: number;
21
+ hours?: number;
22
+ days?: number;
22
23
  };
23
24
  declare function durationObjToMs(durationObj: DurationObj): number;
24
-
25
- export { DAY_AS_MS, DAY_AS_SECS, type DurationObj, HOUR_AS_MS, HOUR_AS_SECS, MINUTE_AS_MS, MONTH_AS_MS, MONTH_AS_SECS, WEEK_AS_MS, WEEK_AS_SECS, YEAR_AS_MS, YEAR_AS_SECS, dateStringOrNullToUnixMs, durationObjToMs, getUnixSeconds, msToTimeString, parseTimeStringToMs };
25
+ //#endregion
26
+ export { DAY_AS_MS, DAY_AS_SECS, DurationObj, HOUR_AS_MS, HOUR_AS_SECS, MINUTE_AS_MS, MONTH_AS_MS, MONTH_AS_SECS, WEEK_AS_MS, WEEK_AS_SECS, YEAR_AS_MS, YEAR_AS_SECS, dateStringOrNullToUnixMs, durationObjToMs, getUnixSeconds, msToTimeString, parseTimeStringToMs };
package/dist/time.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { a as MINUTE_AS_MS, c as WEEK_AS_MS, d as YEAR_AS_SECS, f as dateStringOrNullToUnixMs, g as parseTimeStringToMs, h as msToTimeString, i as HOUR_AS_SECS, l as WEEK_AS_SECS, m as getUnixSeconds, n as DAY_AS_SECS, o as MONTH_AS_MS, p as durationObjToMs, r as HOUR_AS_MS, s as MONTH_AS_SECS, t as DAY_AS_MS, u as YEAR_AS_MS } from "./time-sr2lhQRw.mjs";
2
+
3
+ export { DAY_AS_MS, DAY_AS_SECS, HOUR_AS_MS, HOUR_AS_SECS, MINUTE_AS_MS, MONTH_AS_MS, MONTH_AS_SECS, WEEK_AS_MS, WEEK_AS_SECS, YEAR_AS_MS, YEAR_AS_SECS, dateStringOrNullToUnixMs, durationObjToMs, getUnixSeconds, msToTimeString, parseTimeStringToMs };
@@ -1,5 +1,6 @@
1
- import { Result } from 't-result';
1
+ import { Result } from "t-result";
2
2
 
3
+ //#region src/timers.d.ts
3
4
  type CleanupTimer = () => void;
4
5
  /**
5
6
  * Creates a timeout with automatic cleanup capability.
@@ -70,8 +71,8 @@ declare function createInterval(ms: number, callback: () => void): CleanupTimer;
70
71
  * it
71
72
  */
72
73
  declare function createDebouncedTimeout(ms: number, callback: () => void): {
73
- call: () => void;
74
- clean: CleanupTimer;
74
+ call: () => void;
75
+ clean: CleanupTimer;
75
76
  };
76
77
  /**
77
78
  * Creates a timeout that waits for a condition to become true.
@@ -107,15 +108,23 @@ declare function createDebouncedTimeout(ms: number, callback: () => void): {
107
108
  * milliseconds (default: 20)
108
109
  * @returns A cleanup function that cancels the condition timeout
109
110
  */
110
- declare function createWaitUntil<T extends NonNullable<unknown>>({ condition, maxWaitMs, callback, checkIntervalMs, }: {
111
- condition: () => false | T;
112
- maxWaitMs: number;
113
- callback: (value: T) => void;
114
- checkIntervalMs?: number;
111
+ declare function createWaitUntil<T extends NonNullable<unknown>>({
112
+ condition,
113
+ maxWaitMs,
114
+ callback,
115
+ checkIntervalMs
116
+ }: {
117
+ condition: () => false | T;
118
+ maxWaitMs: number;
119
+ callback: (value: T) => void;
120
+ checkIntervalMs?: number;
115
121
  }): CleanupTimer;
116
- declare function waitFor(condition: () => boolean | Promise<boolean>, { polling, timeout }: {
117
- polling: number | 'raf';
118
- timeout: number;
122
+ declare function waitFor(condition: () => boolean | Promise<boolean>, {
123
+ polling,
124
+ timeout
125
+ }: {
126
+ polling: number | 'raf';
127
+ timeout: number;
119
128
  }): Promise<Result<void, Error>>;
120
-
121
- export { type CleanupTimer, createDebouncedTimeout, createInterval, createTimeout, createWaitUntil, waitFor };
129
+ //#endregion
130
+ export { CleanupTimer, createDebouncedTimeout, createInterval, createTimeout, createWaitUntil, waitFor };