modern-ts 0.8.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 (261) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +223 -0
  3. package/README.zh-CN.md +223 -0
  4. package/dist/chunks/Errors-BWEYu-AB.cjs +2 -0
  5. package/dist/chunks/Errors-BWEYu-AB.cjs.map +1 -0
  6. package/dist/chunks/Errors-DwUAvFIF.mjs +63 -0
  7. package/dist/chunks/Errors-DwUAvFIF.mjs.map +1 -0
  8. package/dist/chunks/Math-CGEH1ClN.mjs +68 -0
  9. package/dist/chunks/Math-CGEH1ClN.mjs.map +1 -0
  10. package/dist/chunks/Math-CWZVxSF-.cjs +2 -0
  11. package/dist/chunks/Math-CWZVxSF-.cjs.map +1 -0
  12. package/dist/chunks/base-B9k8Lqvf.mjs +56 -0
  13. package/dist/chunks/base-B9k8Lqvf.mjs.map +1 -0
  14. package/dist/chunks/base-BTXL1y_I.cjs +2 -0
  15. package/dist/chunks/base-BTXL1y_I.cjs.map +1 -0
  16. package/dist/chunks/base-BpECeKwU.mjs +19 -0
  17. package/dist/chunks/base-BpECeKwU.mjs.map +1 -0
  18. package/dist/chunks/base-BvHqpP_s.cjs +2 -0
  19. package/dist/chunks/base-BvHqpP_s.cjs.map +1 -0
  20. package/dist/chunks/base-K-RHLZ-S.mjs +46 -0
  21. package/dist/chunks/base-K-RHLZ-S.mjs.map +1 -0
  22. package/dist/chunks/base-r6kn0B0D.cjs +2 -0
  23. package/dist/chunks/base-r6kn0B0D.cjs.map +1 -0
  24. package/dist/chunks/combine-async-DcG-3p8i.cjs +2 -0
  25. package/dist/chunks/combine-async-DcG-3p8i.cjs.map +1 -0
  26. package/dist/chunks/combine-async-Dcg4ya1R.mjs +236 -0
  27. package/dist/chunks/combine-async-Dcg4ya1R.mjs.map +1 -0
  28. package/dist/chunks/delay-CG3cD7bk.cjs +2 -0
  29. package/dist/chunks/delay-CG3cD7bk.cjs.map +1 -0
  30. package/dist/chunks/delay-CKIXpP71.mjs +32 -0
  31. package/dist/chunks/delay-CKIXpP71.mjs.map +1 -0
  32. package/dist/chunks/helper-BVabbpmX.mjs +165 -0
  33. package/dist/chunks/helper-BVabbpmX.mjs.map +1 -0
  34. package/dist/chunks/helper-tsqZMRHW.cjs +3 -0
  35. package/dist/chunks/helper-tsqZMRHW.cjs.map +1 -0
  36. package/dist/chunks/local-8JVtLN0O.mjs +10 -0
  37. package/dist/chunks/local-8JVtLN0O.mjs.map +1 -0
  38. package/dist/chunks/local-Da4yU-nE.cjs +2 -0
  39. package/dist/chunks/local-Da4yU-nE.cjs.map +1 -0
  40. package/dist/chunks/types-B7X_LBjM.cjs +2 -0
  41. package/dist/chunks/types-B7X_LBjM.cjs.map +1 -0
  42. package/dist/chunks/types-DE2SnSbz.mjs +5 -0
  43. package/dist/chunks/types-DE2SnSbz.mjs.map +1 -0
  44. package/dist/index.cjs +2 -0
  45. package/dist/index.cjs.map +1 -0
  46. package/dist/index.mjs +759 -0
  47. package/dist/index.mjs.map +1 -0
  48. package/dist/subpath/Arr.cjs +2 -0
  49. package/dist/subpath/Arr.cjs.map +1 -0
  50. package/dist/subpath/Arr.mjs +539 -0
  51. package/dist/subpath/Arr.mjs.map +1 -0
  52. package/dist/subpath/Concurrent.cjs +15 -0
  53. package/dist/subpath/Concurrent.cjs.map +1 -0
  54. package/dist/subpath/Concurrent.mjs +4044 -0
  55. package/dist/subpath/Concurrent.mjs.map +1 -0
  56. package/dist/subpath/FetchQ.cjs +2 -0
  57. package/dist/subpath/FetchQ.cjs.map +1 -0
  58. package/dist/subpath/FetchQ.mjs +519 -0
  59. package/dist/subpath/FetchQ.mjs.map +1 -0
  60. package/dist/subpath/Fit.cjs +2 -0
  61. package/dist/subpath/Fit.cjs.map +1 -0
  62. package/dist/subpath/Fit.mjs +914 -0
  63. package/dist/subpath/Fit.mjs.map +1 -0
  64. package/dist/subpath/Lazy.cjs +2 -0
  65. package/dist/subpath/Lazy.cjs.map +1 -0
  66. package/dist/subpath/Lazy.mjs +72 -0
  67. package/dist/subpath/Lazy.mjs.map +1 -0
  68. package/dist/subpath/Maps.cjs +2 -0
  69. package/dist/subpath/Maps.cjs.map +1 -0
  70. package/dist/subpath/Maps.mjs +123 -0
  71. package/dist/subpath/Maps.mjs.map +1 -0
  72. package/dist/subpath/Maybe.cjs +2 -0
  73. package/dist/subpath/Maybe.cjs.map +1 -0
  74. package/dist/subpath/Maybe.mjs +329 -0
  75. package/dist/subpath/Maybe.mjs.map +1 -0
  76. package/dist/subpath/Reactive.cjs +2 -0
  77. package/dist/subpath/Reactive.cjs.map +1 -0
  78. package/dist/subpath/Reactive.mjs +1204 -0
  79. package/dist/subpath/Reactive.mjs.map +1 -0
  80. package/dist/subpath/Reader.cjs +2 -0
  81. package/dist/subpath/Reader.cjs.map +1 -0
  82. package/dist/subpath/Reader.mjs +75 -0
  83. package/dist/subpath/Reader.mjs.map +1 -0
  84. package/dist/subpath/ReaderT.cjs +2 -0
  85. package/dist/subpath/ReaderT.cjs.map +1 -0
  86. package/dist/subpath/ReaderT.mjs +148 -0
  87. package/dist/subpath/ReaderT.mjs.map +1 -0
  88. package/dist/subpath/Resource.cjs +2 -0
  89. package/dist/subpath/Resource.cjs.map +1 -0
  90. package/dist/subpath/Resource.mjs +150 -0
  91. package/dist/subpath/Resource.mjs.map +1 -0
  92. package/dist/subpath/Result.cjs +2 -0
  93. package/dist/subpath/Result.cjs.map +1 -0
  94. package/dist/subpath/Result.mjs +337 -0
  95. package/dist/subpath/Result.mjs.map +1 -0
  96. package/dist/subpath/Sets.cjs +2 -0
  97. package/dist/subpath/Sets.cjs.map +1 -0
  98. package/dist/subpath/Sets.mjs +92 -0
  99. package/dist/subpath/Sets.mjs.map +1 -0
  100. package/dist/subpath/Str.cjs +2 -0
  101. package/dist/subpath/Str.cjs.map +1 -0
  102. package/dist/subpath/Str.mjs +114 -0
  103. package/dist/subpath/Str.mjs.map +1 -0
  104. package/dist/subpath/TxScope.cjs +2 -0
  105. package/dist/subpath/TxScope.cjs.map +1 -0
  106. package/dist/subpath/TxScope.mjs +138 -0
  107. package/dist/subpath/TxScope.mjs.map +1 -0
  108. package/dist/subpath/TypeTool.cjs +2 -0
  109. package/dist/subpath/TypeTool.cjs.map +1 -0
  110. package/dist/subpath/TypeTool.mjs +9 -0
  111. package/dist/subpath/TypeTool.mjs.map +1 -0
  112. package/dist/subpath/Utils.cjs +2 -0
  113. package/dist/subpath/Utils.cjs.map +1 -0
  114. package/dist/subpath/Utils.mjs +835 -0
  115. package/dist/subpath/Utils.mjs.map +1 -0
  116. package/dist/subpath/VirtualTime.cjs +2 -0
  117. package/dist/subpath/VirtualTime.cjs.map +1 -0
  118. package/dist/subpath/VirtualTime.mjs +1186 -0
  119. package/dist/subpath/VirtualTime.mjs.map +1 -0
  120. package/dist/types/Arr.d.ts +2 -0
  121. package/dist/types/Concurrent/Lock/condition_variable.d.ts +138 -0
  122. package/dist/types/Concurrent/Lock/mutex.d.ts +185 -0
  123. package/dist/types/Concurrent/Lock/rwlock.d.ts +253 -0
  124. package/dist/types/Concurrent/Lock/semaphore.d.ts +208 -0
  125. package/dist/types/Concurrent/Valve/__export__.d.ts +5 -0
  126. package/dist/types/Concurrent/Valve/circuit-breaker.d.ts +146 -0
  127. package/dist/types/Concurrent/Valve/leaky-bucket.d.ts +115 -0
  128. package/dist/types/Concurrent/Valve/sliding-window.d.ts +91 -0
  129. package/dist/types/Concurrent/Valve/token-bucket.d.ts +68 -0
  130. package/dist/types/Concurrent/__export__.d.ts +15 -0
  131. package/dist/types/Concurrent/barrier.d.ts +255 -0
  132. package/dist/types/Concurrent/channel.d.ts +239 -0
  133. package/dist/types/Concurrent/delay.d.ts +42 -0
  134. package/dist/types/Concurrent/ext/map.d.ts +82 -0
  135. package/dist/types/Concurrent/ext/other.d.ts +113 -0
  136. package/dist/types/Concurrent/ext/race.d.ts +31 -0
  137. package/dist/types/Concurrent/ext/some.d.ts +64 -0
  138. package/dist/types/Concurrent/limiter.d.ts +131 -0
  139. package/dist/types/Concurrent/scheduler.d.ts +171 -0
  140. package/dist/types/Concurrent/task-scope.d.ts +282 -0
  141. package/dist/types/Concurrent.d.ts +2 -0
  142. package/dist/types/Errors.d.ts +66 -0
  143. package/dist/types/FetchQ.d.ts +2 -0
  144. package/dist/types/Fit/__export__.d.ts +5 -0
  145. package/dist/types/Fit/base.d.ts +325 -0
  146. package/dist/types/Fit/parser.d.ts +110 -0
  147. package/dist/types/Fit/standard-schema.d.ts +127 -0
  148. package/dist/types/Fit/sugar.d.ts +274 -0
  149. package/dist/types/Fit/tool.d.ts +585 -0
  150. package/dist/types/Fit.d.ts +2 -0
  151. package/dist/types/Lazy.d.ts +2 -0
  152. package/dist/types/Maps.d.ts +2 -0
  153. package/dist/types/Maybe/__export__.d.ts +6 -0
  154. package/dist/types/Maybe/base.d.ts +62 -0
  155. package/dist/types/Maybe/consumers-async.d.ts +58 -0
  156. package/dist/types/Maybe/consumers.d.ts +63 -0
  157. package/dist/types/Maybe/operators-async.d.ts +145 -0
  158. package/dist/types/Maybe/operators.d.ts +177 -0
  159. package/dist/types/Maybe/types.d.ts +12 -0
  160. package/dist/types/Maybe.d.ts +2 -0
  161. package/dist/types/MockClock/Timeline.d.ts +392 -0
  162. package/dist/types/MockClock/TimerHandle.d.ts +159 -0
  163. package/dist/types/MockClock/TimerHeap.d.ts +21 -0
  164. package/dist/types/MockClock/VirtualTimeManager.d.ts +23 -0
  165. package/dist/types/MockClock/__export__.d.ts +104 -0
  166. package/dist/types/MockClock/hooks/__export__.d.ts +9 -0
  167. package/dist/types/MockClock/hooks/hookAbortSignal.d.ts +3 -0
  168. package/dist/types/MockClock/hooks/hookDate.d.ts +3 -0
  169. package/dist/types/MockClock/hooks/hookIntl.d.ts +3 -0
  170. package/dist/types/MockClock/hooks/hookMessageChannel.d.ts +3 -0
  171. package/dist/types/MockClock/hooks/hookMicrotasks.d.ts +3 -0
  172. package/dist/types/MockClock/hooks/hookOs.d.ts +3 -0
  173. package/dist/types/MockClock/hooks/hookPerformance.d.ts +3 -0
  174. package/dist/types/MockClock/hooks/hookProcess.d.ts +3 -0
  175. package/dist/types/MockClock/hooks/hookTimers.d.ts +3 -0
  176. package/dist/types/MockClock/types.d.ts +103 -0
  177. package/dist/types/Other/FetchQ.d.ts +320 -0
  178. package/dist/types/Other/deque.d.ts +59 -0
  179. package/dist/types/Other/disjointSet.d.ts +53 -0
  180. package/dist/types/Other/heap.d.ts +41 -0
  181. package/dist/types/Other/lazy.d.ts +127 -0
  182. package/dist/types/Other/queue.d.ts +42 -0
  183. package/dist/types/Other/secret.d.ts +111 -0
  184. package/dist/types/Other/stack.d.ts +40 -0
  185. package/dist/types/Reactive/__export__.d.ts +4 -0
  186. package/dist/types/Reactive/event_emitter.d.ts +195 -0
  187. package/dist/types/Reactive/flow-combination.d.ts +74 -0
  188. package/dist/types/Reactive/flow.d.ts +180 -0
  189. package/dist/types/Reactive/pace.d.ts +80 -0
  190. package/dist/types/Reactive.d.ts +2 -0
  191. package/dist/types/Reader/__export-readerT__.d.ts +4 -0
  192. package/dist/types/Reader/__export-reader__.d.ts +4 -0
  193. package/dist/types/Reader/local.d.ts +39 -0
  194. package/dist/types/Reader/reader-async.d.ts +84 -0
  195. package/dist/types/Reader/reader.d.ts +96 -0
  196. package/dist/types/Reader/readerT-async.d.ts +186 -0
  197. package/dist/types/Reader/readerT.d.ts +178 -0
  198. package/dist/types/Reader/types.d.ts +37 -0
  199. package/dist/types/Reader.d.ts +2 -0
  200. package/dist/types/ReaderT.d.ts +2 -0
  201. package/dist/types/Resource/TxScope-async.d.ts +86 -0
  202. package/dist/types/Resource/TxScope.d.ts +85 -0
  203. package/dist/types/Resource/__export-TxScope__.d.ts +2 -0
  204. package/dist/types/Resource/__export-resource__.d.ts +2 -0
  205. package/dist/types/Resource/resource-async.d.ts +79 -0
  206. package/dist/types/Resource/resource.d.ts +78 -0
  207. package/dist/types/Resource/types.d.ts +79 -0
  208. package/dist/types/Resource.d.ts +2 -0
  209. package/dist/types/Result/Consumers/branch-async.d.ts +77 -0
  210. package/dist/types/Result/Consumers/branch.d.ts +70 -0
  211. package/dist/types/Result/Consumers/inspect.d.ts +66 -0
  212. package/dist/types/Result/Operators/Async/combine-async.d.ts +69 -0
  213. package/dist/types/Result/Operators/Async/partition-async.d.ts +29 -0
  214. package/dist/types/Result/Operators/Async/reduce-async.d.ts +15 -0
  215. package/dist/types/Result/Operators/Async/transform-async.d.ts +90 -0
  216. package/dist/types/Result/Operators/combine.d.ts +60 -0
  217. package/dist/types/Result/Operators/flatten.d.ts +26 -0
  218. package/dist/types/Result/Operators/partition.d.ts +25 -0
  219. package/dist/types/Result/Operators/reduce.d.ts +12 -0
  220. package/dist/types/Result/Operators/transform.d.ts +70 -0
  221. package/dist/types/Result/__export__.d.ts +14 -0
  222. package/dist/types/Result/base.d.ts +115 -0
  223. package/dist/types/Result/types.d.ts +34 -0
  224. package/dist/types/Result.d.ts +2 -0
  225. package/dist/types/Sets.d.ts +2 -0
  226. package/dist/types/Str.d.ts +2 -0
  227. package/dist/types/TxScope.d.ts +2 -0
  228. package/dist/types/TypeTool.d.ts +2 -0
  229. package/dist/types/Utils/Array/__export__.d.ts +10 -0
  230. package/dist/types/Utils/Array/filtering.d.ts +89 -0
  231. package/dist/types/Utils/Array/flatten.d.ts +45 -0
  232. package/dist/types/Utils/Array/grouping.d.ts +44 -0
  233. package/dist/types/Utils/Array/iteration.d.ts +86 -0
  234. package/dist/types/Utils/Array/operators.d.ts +62 -0
  235. package/dist/types/Utils/Array/randomization.d.ts +76 -0
  236. package/dist/types/Utils/Array/set.d.ts +108 -0
  237. package/dist/types/Utils/Array/slice.d.ts +189 -0
  238. package/dist/types/Utils/Array/sorting.d.ts +55 -0
  239. package/dist/types/Utils/Array/zip.d.ts +93 -0
  240. package/dist/types/Utils/Functions/__export__.d.ts +5 -0
  241. package/dist/types/Utils/Functions/base.d.ts +157 -0
  242. package/dist/types/Utils/Functions/curry.d.ts +73 -0
  243. package/dist/types/Utils/Functions/debounce.d.ts +240 -0
  244. package/dist/types/Utils/Functions/defer.d.ts +43 -0
  245. package/dist/types/Utils/Functions/pipe.d.ts +205 -0
  246. package/dist/types/Utils/Map.d.ts +284 -0
  247. package/dist/types/Utils/Math.d.ts +225 -0
  248. package/dist/types/Utils/Object/__export__.d.ts +2 -0
  249. package/dist/types/Utils/Object/base.d.ts +131 -0
  250. package/dist/types/Utils/Object/clone.d.ts +81 -0
  251. package/dist/types/Utils/Predicates.d.ts +361 -0
  252. package/dist/types/Utils/Set.d.ts +105 -0
  253. package/dist/types/Utils/String.d.ts +217 -0
  254. package/dist/types/Utils/__export__.d.ts +9 -0
  255. package/dist/types/Utils/type-tool.d.ts +168 -0
  256. package/dist/types/Utils.d.ts +2 -0
  257. package/dist/types/VirtualTime.d.ts +2 -0
  258. package/dist/types/helper.d.ts +71 -0
  259. package/dist/types/index.d.ts +21 -0
  260. package/dist/types/unknown-error.d.ts +98 -0
  261. package/package.json +179 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but not
32
+ limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2024-2026 HiraethCyan
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,223 @@
1
+ # modern-ts
2
+
3
+ <div align="center">
4
+
5
+ **A Modern TypeScript Standard Suite**
6
+
7
+ Self-contained · Zero Dependencies · 100% Coverage · Tree-shakeable · High Performance
8
+
9
+ </div>
10
+
11
+ > ⚠️ **Beta Notice**: Currently in beta phase, collecting community feedback. API may undergo breaking changes at any time. Use with caution in production environments.
12
+
13
+ ---
14
+
15
+ ## Features
16
+
17
+ - **Self-contained**: No runtime dependencies, ready to use out of the box
18
+ - **Zero Dependencies**: Keeps the project lightweight, avoids supply chain risks
19
+ - **100% Coverage**: Comprehensive test coverage ensures code quality
20
+ - **Tree-shakeable**: Supports tree-shaking for on-demand imports
21
+ - **High Performance**: Key modules are deeply optimized, outperforming similar libraries
22
+
23
+ ## Module Overview
24
+
25
+ ### 🔄 Concurrent — Concurrency Primitives
26
+
27
+ A comprehensive collection of system-level concurrency primitives:
28
+
29
+ | Submodule | Description |
30
+ | ------------- | ------------------------------------------------------------------------------- |
31
+ | **Lock** | `Mutex`, `Semaphore`, `ConditionVariable`, `RwLock` and other concurrency locks |
32
+ | **Valve** | `TokenBucket`, `LeakyBucket`, `SlidingWindow`, `CircuitBreaker` flow control |
33
+ | **Limit** | Concurrent task quantity control (more complete than `p-limit`) |
34
+ | **Channel** | Go language CSP model implementation |
35
+ | **Scheduler** | CFS-Like cooperative async scheduler |
36
+ | **TaskScope** | Structured concurrency scope |
37
+
38
+ ### ⏰ MockClock — Mock Clock
39
+
40
+ A mock clock based on `AsyncLocalStorage`, supports concurrent testing with deep simulation of `NodeJS.Timeout` handles.
41
+
42
+ ### 🎭 Monad — Common Functional Primitives
43
+
44
+ | Module | Purpose |
45
+ | ---------- | -------------------- |
46
+ | **Result** | Error handling |
47
+ | **Maybe** | Optional values |
48
+ | **Reader** | Dependency injection |
49
+
50
+ ### 🛠️ Utils — Utility Functions
51
+
52
+ A comprehensive utility function library (similar to `lodash`):
53
+
54
+ - Type-safe `curry` / `pipe` (supports placeholders and deep inference)
55
+ - High-performance `debounce` / `throttle` (more robust edge handling than `lodash`)
56
+ - Deep copy `cloneDeep` (supports circular references, stack-based implementation, handles 100k+ nesting levels)
57
+ - Common type utilities, array, object, function, string, Map/Set utility functions
58
+
59
+ ### 🌐 FetchQ — HTTP Client
60
+
61
+ A feature-rich HTTP client using the Result pattern.
62
+
63
+ ### ✅ Fit — Schema Validation
64
+
65
+ A type-first, tree-shakeable, and highly extensible schema validation library.
66
+
67
+ ### 📦 Other Modules
68
+
69
+ | Module | Description |
70
+ | ---------------- | ----------------------------------------------------------------------------------------------------------------------------- |
71
+ | **Other** | Common data structures (Deque, Heap, Queue, Stack, DisjointSet) and utility functions |
72
+ | **Resource** | RAII resource manager based on `using` |
73
+ | **Flow** | RxJS-like reactive primitives with inversion of control |
74
+ | **EventEmitter** | Cross-platform EventEmitter with nearly identical behavior and superior performance metrics compared to Node.js native module |
75
+
76
+ ## Installation
77
+
78
+ ```bash
79
+ # pnpm
80
+ pnpm add modern-ts
81
+
82
+ # npm
83
+ npm install modern-ts
84
+
85
+ # yarn
86
+ yarn add modern-ts
87
+ ```
88
+
89
+ ## Quick Start
90
+
91
+ ### Import Methods
92
+
93
+ The library supports multiple import methods:
94
+
95
+ ```typescript
96
+ // Import all
97
+ import * as Modern from 'modern-ts';
98
+
99
+ // Import by namespace
100
+ import { Result, Maybe } from 'modern-ts';
101
+
102
+ // Subpath import (tree-shaking optimized)
103
+ import { Ok, Err } from 'modern-ts/Result';
104
+ import { Some, None } from 'modern-ts/Maybe';
105
+ import { Mutex } from 'modern-ts/Concurrent';
106
+ import { debounce, throttle } from 'modern-ts/Utils';
107
+ ```
108
+
109
+ ### Example: Result Error Handling
110
+
111
+ ```typescript
112
+ import { Ok, Err, Result, isOk } from 'modern-ts/Result';
113
+
114
+ function divide(a: number, b: number): Result<number, string> {
115
+ if (b === 0) return Err('Division by zero');
116
+ return Ok(a / b);
117
+ }
118
+
119
+ const result = divide(10, 2);
120
+ if (isOk(result)) {
121
+ console.log(result.value); // 5
122
+ }
123
+ ```
124
+
125
+ ### Example: Fit Schema Validation
126
+
127
+ ```typescript
128
+ import * as f from 'modern-ts/Fit';
129
+
130
+ const UserSchema = f
131
+ .fit<{name: string; age: number; tags: string[]} | 'VIP'>()
132
+ .off((v) => v === 'VIP', 'ok') // Short-circuit return 'ok' if VIP
133
+ .toShaped({
134
+ name: f.String().that(f.min_len(2)),
135
+ age: f.Number().that(f.range(0, 150)),
136
+ tags: f.items(f.String()),
137
+ });
138
+
139
+ const result = f.validate({name: 'Alice', age: 25, tags: ['dev']}, UserSchema);
140
+ /*
141
+ result.ok === true, result.value is the validated object with type:
142
+ "ok" | {
143
+ name: string;
144
+ age: number;
145
+ tags: string[];
146
+ }
147
+ */
148
+ ```
149
+
150
+ ### Example: MockClock Concurrent Time Simulation
151
+
152
+ ```typescript
153
+ import { MockClock, withTimelineAsync } from 'modern-ts/VirtualTime';
154
+
155
+ // Concurrent testing: two independent timelines, isolated from each other
156
+ const [t1, t2] = await Promise.all([
157
+ withTimelineAsync(MockClock(), async (clock) => {
158
+ clock.setSystemTime(1000); // Set start time
159
+ return Date.now(); // 1000
160
+ }),
161
+ withTimelineAsync(MockClock(), async (clock) => {
162
+ clock.setSystemTime(2000); // Different start time
163
+ return Date.now(); // 2000
164
+ }),
165
+ ]);
166
+ // t1 === 1000, t2 === 2000 (timeline isolation)
167
+ ```
168
+
169
+ ### Example: Scheduler Cooperative Scheduling
170
+
171
+ ```typescript
172
+ import { Scheduler } from 'modern-ts/Concurrent';
173
+
174
+ const scheduler = new Scheduler(1);
175
+ const log: string[] = [];
176
+
177
+ // Tasks yield control via pause() for cooperative scheduling
178
+ await Promise.all([
179
+ scheduler.add(async (_, pause) => {
180
+ log.push('A-start');
181
+ await pause({ nice: 10 }); // Lower priority, yield execution
182
+ log.push('A-resume');
183
+ }),
184
+ scheduler.add(() => log.push('B-run'), { nice: -5 }), // Higher priority
185
+ ]);
186
+
187
+ // Execution order: A-start → B-run → A-resume
188
+ ```
189
+
190
+ ## Subpath Exports
191
+
192
+ | Path | Description |
193
+ | ----------------------- | --------------------------- |
194
+ | `modern-ts/Result` | Result error handling |
195
+ | `modern-ts/Maybe` | Maybe optional values |
196
+ | `modern-ts/Reader` | Reader dependency injection |
197
+ | `modern-ts/ReaderT` | ReaderT monad transformer |
198
+ | `modern-ts/Resource` | RAII resource management |
199
+ | `modern-ts/TxScope` | RAII transaction scope |
200
+ | `modern-ts/Lazy` | Lazy evaluation |
201
+ | `modern-ts/LiteQ` | Lightweight queue |
202
+ | `modern-ts/Fit` | Schema validation |
203
+ | `modern-ts/VirtualTime` | Virtual time |
204
+ | `modern-ts/Concurrent` | Concurrency primitives |
205
+ | `modern-ts/Reactive` | Reactive primitives |
206
+ | `modern-ts/Utils` | Utility functions |
207
+ | `modern-ts/Arr` | Array utilities |
208
+ | `modern-ts/Str` | String utilities |
209
+ | `modern-ts/Sets` | Set utilities |
210
+ | `modern-ts/Maps` | Map utilities |
211
+
212
+ ## API Documentation
213
+
214
+ For detailed API documentation, see the [docs/en](./docs/en) directory.
215
+
216
+ ## Requirements
217
+
218
+ - Node.js >= 20
219
+ - TypeScript >= 5.0
220
+
221
+ ## License
222
+
223
+ [Apache-2.0](./LICENSE)
@@ -0,0 +1,223 @@
1
+ # modern-ts
2
+
3
+ <div align="center">
4
+
5
+ **一个现代 TypeScript 标准套件**
6
+
7
+ 自包含 · 零依赖 · 100% 覆盖率 · 摇树友好 · 高性能
8
+
9
+ </div>
10
+
11
+ > ⚠️ **测试版本提示**:当前处于测试阶段,正在收集社区反馈。API 可能随时发生破坏性更新,请谨慎用于生产环境
12
+
13
+ ***
14
+
15
+ ## 特性
16
+
17
+ - **自包含**:无任何运行时依赖,开箱即用
18
+ - **零依赖**:保持项目轻量,避免供应链风险
19
+ - **100% 覆盖率**:完善的测试覆盖,确保代码质量
20
+ - **摇树友好**:支持 Tree-shaking,按需引入
21
+ - **高性能**:关键模块经过深度优化,性能优于同类库
22
+
23
+ ## 模块概览
24
+
25
+ ### 🔄 Concurrent — 并发原语
26
+
27
+ 完善的系统级并发原语集合:
28
+
29
+ | 子模块 | 说明 |
30
+ | ------------- | ----------------------------------------------------------------- |
31
+ | **Lock** | `Mutex`、`Semaphore`、`ConditionVariable`、`RwLock` 等并发锁 |
32
+ | **Valve** | `TokenBucket`、`LeakyBucket`、`SlidingWindow`、`CircuitBreaker` 流量控制 |
33
+ | **Limit** | 并发任务数量控制(比 `p-limit` 更完善) |
34
+ | **Channel** | Go 语言 CSP 模型实现 |
35
+ | **Scheduler** | CFS-Like 协作式异步调度器 |
36
+ | **TaskScope** | 结构化并发作用域 |
37
+
38
+ ### ⏰ MockClock — 模拟时钟
39
+
40
+ 基于 `AsyncLocalStorage` 的模拟时钟,支持并发测试,深度模拟 `NodeJS.Timeout` 句柄。
41
+
42
+ ### 🎭 Monad — 常用的函数式原语
43
+
44
+ | 模块 | 用途 |
45
+ | ---------- | ----- |
46
+ | **Result** | 错误处理 |
47
+ | **Maybe** | 可选值处理 |
48
+ | **Reader** | 依赖注入 |
49
+
50
+ ### 🛠️ Utils — 工具函数
51
+
52
+ 完善的工具函数库(近似 `lodash`):
53
+
54
+ - 类型安全的 `curry` / `pipe`(支持占位符和深层推导)
55
+ - 高性能 `debounce` / `throttle`(边缘处理比`lodash`更健壮)
56
+ - 深拷贝 `cloneDeep`(支持循环引用,手写栈实现,十万级嵌套)
57
+ - 常用类型工具、数组、对象、函数、字符串、Map/Set 工具函数
58
+
59
+ ### 🌐 FetchQ — HTTP 客户端
60
+
61
+ 支持复杂功能、采用 Result 模式的 HTTP 客户端。
62
+
63
+ ### ✅ Fit — Schema 验证
64
+
65
+ 类型优先、摇树友好、扩展性极强的 Schema 验证库。
66
+
67
+ ### 📦 其他模块
68
+
69
+ | 模块 | 说明 |
70
+ | ---------------- | ----------------------------------------------- |
71
+ | **Other** | 常用数据结构(Deque、Heap、Queue、Stack、DisjointSet)及工具函数 |
72
+ | **Resource** | 基于 `using` 的 RAII 资源管理器 |
73
+ | **Flow** | 类似 RxJS 的响应式原语,支持控制权反转 |
74
+ | **EventEmitter** | 跨平台 EventEmitter,行为几乎无异的同时多项性能指标优于 Node.js 原生模块 |
75
+
76
+ ## 安装
77
+
78
+ ```bash
79
+ # pnpm
80
+ pnpm add modern-ts
81
+
82
+ # npm
83
+ npm install modern-ts
84
+
85
+ # yarn
86
+ yarn add modern-ts
87
+ ```
88
+
89
+ ## 快速开始
90
+
91
+ ### 导入方式
92
+
93
+ 库支持多种导入方式:
94
+
95
+ ```typescript
96
+ // 导入所有
97
+ import * as Modern from 'modern-ts';
98
+
99
+ // 按命名空间导入
100
+ import { Result, Maybe } from 'modern-ts';
101
+
102
+ // 子路径导入(摇树优化)
103
+ import { Ok, Err } from 'modern-ts/Result';
104
+ import { Some, None } from 'modern-ts/Maybe';
105
+ import { Mutex } from 'modern-ts/Concurrent';
106
+ import { debounce, throttle } from 'modern-ts/Utils';
107
+ ```
108
+
109
+ ### 示例:Result 错误处理
110
+
111
+ ```typescript
112
+ import { Ok, Err, Result, isOk } from 'modern-ts/Result';
113
+
114
+ function divide(a: number, b: number): Result<number, string> {
115
+ if (b === 0) return Err('Division by zero');
116
+ return Ok(a / b);
117
+ }
118
+
119
+ const result = divide(10, 2);
120
+ if (isOk(result)) {
121
+ console.log(result.value); // 5
122
+ }
123
+ ```
124
+
125
+ ### 示例:Fit Schema 验证
126
+
127
+ ```typescript
128
+ import * as f from 'modern-ts/Fit';
129
+
130
+ const UserSchema = f
131
+ .fit<{name: string; age: number; tags: string[]} | 'VIP'>()
132
+ .off((v) => v === 'VIP', 'ok') // 如果是VIP,直接短路返回ok
133
+ .toShaped({
134
+ name: f.String().that(f.min_len(2)),
135
+ age: f.Number().that(f.range(0, 150)),
136
+ tags: f.items(f.String()),
137
+ });
138
+
139
+ const result = f.validate({name: 'Alice', age: 25, tags: ['dev']}, UserSchema);
140
+ /*
141
+ result.ok === true, result.value 为验证后的对象,类型如下:
142
+ "ok" | {
143
+ name: string;
144
+ age: number;
145
+ tags: string[];
146
+ }
147
+ */
148
+ ```
149
+
150
+ ### 示例:MockClock 并发时间模拟
151
+
152
+ ```typescript
153
+ import { MockClock, withTimelineAsync } from 'modern-ts/VirtualTime';
154
+
155
+ // 并发测试:两个独立时间线,互不干扰
156
+ const [t1, t2] = await Promise.all([
157
+ withTimelineAsync(MockClock(), async (clock) => {
158
+ clock.setSystemTime(1000); // 设置起始时间
159
+ return Date.now(); // 1000
160
+ }),
161
+ withTimelineAsync(MockClock(), async (clock) => {
162
+ clock.setSystemTime(2000); // 不同的起始时间
163
+ return Date.now(); // 2000
164
+ }),
165
+ ]);
166
+ // t1 === 1000, t2 === 2000(时间线隔离)
167
+ ```
168
+
169
+ ### 示例:Scheduler 协作式调度
170
+
171
+ ```typescript
172
+ import { Scheduler } from 'modern-ts/Concurrent';
173
+
174
+ const scheduler = new Scheduler(1);
175
+ const log: string[] = [];
176
+
177
+ // 任务通过 pause() 让出控制权,实现协作式调度
178
+ await Promise.all([
179
+ scheduler.add(async (_, pause) => {
180
+ log.push('A-start');
181
+ await pause({ nice: 10 }); // 降低优先级,让出执行权
182
+ log.push('A-resume');
183
+ }),
184
+ scheduler.add(() => log.push('B-run'), { nice: -5 }), // 高优先级
185
+ ]);
186
+
187
+ // 执行顺序: A-start → B-run → A-resume
188
+ ```
189
+
190
+ ## 子路径导出
191
+
192
+ | 路径 | 说明 |
193
+ | ----------------------- | ------------- |
194
+ | `modern-ts/Result` | Result 错误处理 |
195
+ | `modern-ts/Maybe` | Maybe 可选值 |
196
+ | `modern-ts/Reader` | Reader 依赖注入 |
197
+ | `modern-ts/ReaderT` | ReaderT 单子转换器 |
198
+ | `modern-ts/Resource` | RAII 资源管理 |
199
+ | `modern-ts/TxScope` | RAII 事务作用域 |
200
+ | `modern-ts/Lazy` | 延迟计算 |
201
+ | `modern-ts/LiteQ` | 轻量级队列 |
202
+ | `modern-ts/Fit` | Schema 验证 |
203
+ | `modern-ts/VirtualTime` | 虚拟时间 |
204
+ | `modern-ts/Concurrent` | 并发原语 |
205
+ | `modern-ts/Reactive` | 响应式原语 |
206
+ | `modern-ts/Utils` | 工具函数 |
207
+ | `modern-ts/Arr` | 数组工具 |
208
+ | `modern-ts/Str` | 字符串工具 |
209
+ | `modern-ts/Sets` | Set 工具 |
210
+ | `modern-ts/Maps` | Map 工具 |
211
+
212
+ ## API 文档
213
+
214
+ 详细的 API 文档请参阅 [docs/zh-CN](./docs/zh-CN) 目录)
215
+
216
+ ## 环境要求
217
+
218
+ - Node.js >= 20
219
+ - TypeScript >= 5.0
220
+
221
+ ## 许可证
222
+
223
+ [Apache-2.0](./LICENSE)
@@ -0,0 +1,2 @@
1
+ "use strict";class e extends Error{constructor(r){super(r),this.name="UseAfterFreeError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e)}}class t extends Error{constructor(r){super(r),this.name="LockError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t)}}class c extends t{constructor(r){super(r),this.name="MutexError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,c)}}class o extends t{constructor(r){super(r),this.name="RWLockError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,o)}}class a extends Error{constructor(r){super(r),this.name="ParameterError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,a)}}class s extends Error{constructor(r="Flow completed before run could finish"){super(r),this.name="FlowCompletionError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,s)}}exports.FlowCompletionError=s;exports.LockError=t;exports.MutexError=c;exports.ParameterError=a;exports.RWLockError=o;exports.UseAfterFreeError=e;
2
+ //# sourceMappingURL=Errors-BWEYu-AB.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Errors-BWEYu-AB.cjs","sources":["../../src/Errors.ts"],"sourcesContent":["// ========================================\r\n// ./src/Errors.ts\r\n// ========================================\r\n/* v8 ignore file -- @preserve */\r\n\r\n/**\r\n * Error thrown when a resource is accessed after it has been disposed (Use After Free).\r\n */\r\nexport class UseAfterFreeError extends Error {\r\n /**\r\n * Creates an instance of UseAfterFreeError.\r\n * @param message - The error message. Defaults to 'Cannot access resource after it has been disposed.'\r\n */\r\n constructor(message: string) {\r\n super(message);\r\n this.name = 'UseAfterFreeError';\r\n if (typeof Error.captureStackTrace === 'function')\r\n Error.captureStackTrace(this, UseAfterFreeError);\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when a lock operation fails.\r\n * Base class for all lock-related errors.\r\n */\r\nexport class LockError extends Error {\r\n /**\r\n * Creates an instance of LockError.\r\n * @param message - The error message describing the lock failure.\r\n */\r\n constructor(message: string) {\r\n super(message);\r\n this.name = 'LockError';\r\n if (typeof Error.captureStackTrace === 'function')\r\n Error.captureStackTrace(this, LockError);\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when a mutex operation fails.\r\n * Used for mutual exclusion lock violations and failures.\r\n */\r\nexport class MutexError extends LockError {\r\n /**\r\n * Creates an instance of MutexError.\r\n * @param message - The error message describing the mutex failure.\r\n */\r\n constructor(message: string) {\r\n super(message);\r\n this.name = 'MutexError';\r\n if (typeof Error.captureStackTrace === 'function')\r\n Error.captureStackTrace(this, MutexError);\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when a read-write lock operation fails.\r\n * Used for reader-writer lock violations and failures.\r\n */\r\nexport class RWLockError extends LockError {\r\n /**\r\n * Creates an instance of RWLockError.\r\n * @param message - The error message describing the read-write lock failure.\r\n */\r\n constructor(message: string) {\r\n super(message);\r\n this.name = 'RWLockError';\r\n if (typeof Error.captureStackTrace === 'function')\r\n Error.captureStackTrace(this, RWLockError);\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when a function parameter is invalid.\r\n * Used for parameter validation failures.\r\n */\r\nexport class ParameterError extends Error {\r\n /**\r\n * Creates an instance of ParameterError.\r\n * @param message - The error message describing the parameter validation failure.\r\n */\r\n constructor(message: string) {\r\n super(message);\r\n this.name = 'ParameterError';\r\n if (typeof Error.captureStackTrace === 'function')\r\n Error.captureStackTrace(this, ParameterError);\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when a Flow completes before a run operation could finish.\r\n * This indicates that the Flow was completed or stopped while there were\r\n * still pending operations waiting for values.\r\n */\r\nexport class FlowCompletionError extends Error {\r\n /**\r\n * Creates an instance of FlowCompletionError.\r\n * @param message - The error message. Defaults to 'Flow completed before run could finish'.\r\n */\r\n constructor(message: string = 'Flow completed before run could finish') {\r\n super(message);\r\n this.name = 'FlowCompletionError';\r\n if (typeof Error.captureStackTrace === 'function')\r\n Error.captureStackTrace(this, FlowCompletionError);\r\n }\r\n}\r\n"],"names":["UseAfterFreeError","message","LockError","MutexError","RWLockError","ParameterError","FlowCompletionError"],"mappings":"aAQO,MAAMA,UAA0B,KAAM,CAK3C,YAAYC,EAAiB,CAC3B,MAAMA,CAAO,EACb,KAAK,KAAO,oBACR,OAAO,MAAM,mBAAsB,YACrC,MAAM,kBAAkB,KAAMD,CAAiB,CACnD,CACF,CAMO,MAAME,UAAkB,KAAM,CAKnC,YAAYD,EAAiB,CAC3B,MAAMA,CAAO,EACb,KAAK,KAAO,YACR,OAAO,MAAM,mBAAsB,YACrC,MAAM,kBAAkB,KAAMC,CAAS,CAC3C,CACF,CAMO,MAAMC,UAAmBD,CAAU,CAKxC,YAAYD,EAAiB,CAC3B,MAAMA,CAAO,EACb,KAAK,KAAO,aACR,OAAO,MAAM,mBAAsB,YACrC,MAAM,kBAAkB,KAAME,CAAU,CAC5C,CACF,CAMO,MAAMC,UAAoBF,CAAU,CAKzC,YAAYD,EAAiB,CAC3B,MAAMA,CAAO,EACb,KAAK,KAAO,cACR,OAAO,MAAM,mBAAsB,YACrC,MAAM,kBAAkB,KAAMG,CAAW,CAC7C,CACF,CAMO,MAAMC,UAAuB,KAAM,CAKxC,YAAYJ,EAAiB,CAC3B,MAAMA,CAAO,EACb,KAAK,KAAO,iBACR,OAAO,MAAM,mBAAsB,YACrC,MAAM,kBAAkB,KAAMI,CAAc,CAChD,CACF,CAOO,MAAMC,UAA4B,KAAM,CAK7C,YAAYL,EAAkB,yCAA0C,CACtE,MAAMA,CAAO,EACb,KAAK,KAAO,sBACR,OAAO,MAAM,mBAAsB,YACrC,MAAM,kBAAkB,KAAMK,CAAmB,CACrD,CACF"}