@typed/fx 1.18.4 → 1.20.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 (423) hide show
  1. package/AsyncData/package.json +6 -0
  2. package/Emitter/package.json +6 -0
  3. package/Form/package.json +6 -0
  4. package/FormEntry/package.json +6 -0
  5. package/Fx/package.json +6 -0
  6. package/Guard/package.json +6 -0
  7. package/Idle/package.json +6 -0
  8. package/Match/package.json +6 -0
  9. package/Pull/package.json +6 -0
  10. package/Push/package.json +6 -0
  11. package/RefArray/package.json +6 -0
  12. package/RefChunk/package.json +6 -0
  13. package/RefHashMap/package.json +6 -0
  14. package/RefHashSet/package.json +6 -0
  15. package/RefSubject/package.json +6 -0
  16. package/Sink/package.json +6 -0
  17. package/Stream/package.json +6 -0
  18. package/Subject/package.json +6 -0
  19. package/TypeId/package.json +6 -0
  20. package/Typeclass/package.json +6 -0
  21. package/Versioned/package.json +6 -0
  22. package/dist/cjs/AsyncData.js +177 -0
  23. package/dist/cjs/AsyncData.js.map +1 -0
  24. package/dist/cjs/Emitter.js +24 -21
  25. package/dist/cjs/Emitter.js.map +1 -1
  26. package/dist/cjs/Form.js +78 -21
  27. package/dist/cjs/Form.js.map +1 -1
  28. package/dist/cjs/FormEntry.js +75 -48
  29. package/dist/cjs/FormEntry.js.map +1 -1
  30. package/dist/cjs/Fx.js +517 -872
  31. package/dist/cjs/Fx.js.map +1 -1
  32. package/dist/cjs/Guard.js +21 -13
  33. package/dist/cjs/Guard.js.map +1 -1
  34. package/dist/cjs/Idle.js +49 -37
  35. package/dist/cjs/Idle.js.map +1 -1
  36. package/dist/cjs/Match.js +99 -61
  37. package/dist/cjs/Match.js.map +1 -1
  38. package/dist/cjs/Pull.js.map +1 -1
  39. package/dist/cjs/Push.js +168 -0
  40. package/dist/cjs/Push.js.map +1 -0
  41. package/dist/cjs/RefArray.js +32 -30
  42. package/dist/cjs/RefArray.js.map +1 -1
  43. package/dist/cjs/RefChunk.js +26 -24
  44. package/dist/cjs/RefChunk.js.map +1 -1
  45. package/dist/cjs/RefHashMap.js +20 -20
  46. package/dist/cjs/RefHashMap.js.map +1 -1
  47. package/dist/cjs/RefHashSet.js +11 -8
  48. package/dist/cjs/RefHashSet.js.map +1 -1
  49. package/dist/cjs/RefSubject.js +899 -158
  50. package/dist/cjs/RefSubject.js.map +1 -1
  51. package/dist/cjs/Sink.js +588 -62
  52. package/dist/cjs/Sink.js.map +1 -1
  53. package/dist/cjs/Stream.js +15 -10
  54. package/dist/cjs/Stream.js.map +1 -1
  55. package/dist/cjs/Subject.js +153 -55
  56. package/dist/cjs/Subject.js.map +1 -1
  57. package/dist/cjs/TypeId.js +10 -5
  58. package/dist/cjs/TypeId.js.map +1 -1
  59. package/dist/cjs/Typeclass.js +28 -31
  60. package/dist/cjs/Typeclass.js.map +1 -1
  61. package/dist/cjs/Versioned.js +118 -57
  62. package/dist/cjs/Versioned.js.map +1 -1
  63. package/dist/cjs/index.js +44 -8
  64. package/dist/cjs/index.js.map +1 -1
  65. package/dist/cjs/internal/{deferred-ref.js → DeferredRef.js} +45 -13
  66. package/dist/cjs/internal/DeferredRef.js.map +1 -0
  67. package/dist/cjs/internal/UnionToTuple.js +6 -0
  68. package/dist/cjs/internal/UnionToTuple.js.map +1 -0
  69. package/dist/cjs/internal/core.js +1590 -779
  70. package/dist/cjs/internal/core.js.map +1 -1
  71. package/dist/cjs/internal/diff.js +114 -0
  72. package/dist/cjs/internal/diff.js.map +1 -0
  73. package/dist/cjs/internal/effect-loop-operator.js +288 -0
  74. package/dist/cjs/internal/effect-loop-operator.js.map +1 -0
  75. package/dist/cjs/internal/effect-operator.js +46 -37
  76. package/dist/cjs/internal/effect-operator.js.map +1 -1
  77. package/dist/cjs/internal/effect-producer.js +74 -0
  78. package/dist/cjs/internal/effect-producer.js.map +1 -0
  79. package/dist/cjs/internal/helpers.js +158 -128
  80. package/dist/cjs/internal/helpers.js.map +1 -1
  81. package/dist/cjs/internal/keyed.js +136 -173
  82. package/dist/cjs/internal/keyed.js.map +1 -1
  83. package/dist/cjs/internal/loop-operator.js +213 -0
  84. package/dist/cjs/internal/loop-operator.js.map +1 -0
  85. package/dist/cjs/internal/operator.js +79 -0
  86. package/dist/cjs/internal/operator.js.map +1 -0
  87. package/dist/cjs/internal/protos.js +19 -81
  88. package/dist/cjs/internal/protos.js.map +1 -1
  89. package/dist/cjs/internal/provide.js +47 -25
  90. package/dist/cjs/internal/provide.js.map +1 -1
  91. package/dist/cjs/internal/requestIdleCallback.js +5 -5
  92. package/dist/cjs/internal/requestIdleCallback.js.map +1 -1
  93. package/dist/cjs/internal/share.js +12 -15
  94. package/dist/cjs/internal/share.js.map +1 -1
  95. package/dist/cjs/internal/sync-operator.js +50 -22
  96. package/dist/cjs/internal/sync-operator.js.map +1 -1
  97. package/dist/cjs/internal/sync-producer.js +114 -0
  98. package/dist/cjs/internal/sync-producer.js.map +1 -0
  99. package/dist/cjs/internal/withKey.js +45 -51
  100. package/dist/cjs/internal/withKey.js.map +1 -1
  101. package/dist/dts/AsyncData.d.ts +185 -0
  102. package/dist/dts/AsyncData.d.ts.map +1 -0
  103. package/dist/dts/Emitter.d.ts +13 -20
  104. package/dist/dts/Emitter.d.ts.map +1 -1
  105. package/dist/dts/Form.d.ts +45 -28
  106. package/dist/dts/Form.d.ts.map +1 -1
  107. package/dist/dts/FormEntry.d.ts +25 -13
  108. package/dist/dts/FormEntry.d.ts.map +1 -1
  109. package/dist/dts/Fx.d.ts +983 -1387
  110. package/dist/dts/Fx.d.ts.map +1 -1
  111. package/dist/dts/Guard.d.ts +8 -1
  112. package/dist/dts/Guard.d.ts.map +1 -1
  113. package/dist/dts/Idle.d.ts +3 -3
  114. package/dist/dts/Idle.d.ts.map +1 -1
  115. package/dist/dts/Match.d.ts +8 -8
  116. package/dist/dts/Match.d.ts.map +1 -1
  117. package/dist/dts/Pull.d.ts +5 -5
  118. package/dist/dts/Pull.d.ts.map +1 -1
  119. package/dist/dts/Push.d.ts +170 -0
  120. package/dist/dts/Push.d.ts.map +1 -0
  121. package/dist/dts/RefArray.d.ts +21 -23
  122. package/dist/dts/RefArray.d.ts.map +1 -1
  123. package/dist/dts/RefChunk.d.ts +17 -19
  124. package/dist/dts/RefChunk.d.ts.map +1 -1
  125. package/dist/dts/RefHashMap.d.ts +19 -20
  126. package/dist/dts/RefHashMap.d.ts.map +1 -1
  127. package/dist/dts/RefHashSet.d.ts +12 -16
  128. package/dist/dts/RefHashSet.d.ts.map +1 -1
  129. package/dist/dts/RefSubject.d.ts +396 -187
  130. package/dist/dts/RefSubject.d.ts.map +1 -1
  131. package/dist/dts/Sink.d.ts +193 -93
  132. package/dist/dts/Sink.d.ts.map +1 -1
  133. package/dist/dts/Stream.d.ts +7 -1
  134. package/dist/dts/Stream.d.ts.map +1 -1
  135. package/dist/dts/Subject.d.ts +27 -36
  136. package/dist/dts/Subject.d.ts.map +1 -1
  137. package/dist/dts/TypeId.d.ts +10 -0
  138. package/dist/dts/TypeId.d.ts.map +1 -1
  139. package/dist/dts/Typeclass.d.ts +2 -2
  140. package/dist/dts/Typeclass.d.ts.map +1 -1
  141. package/dist/dts/Versioned.d.ts +50 -78
  142. package/dist/dts/Versioned.d.ts.map +1 -1
  143. package/dist/dts/index.d.ts +66 -6
  144. package/dist/dts/index.d.ts.map +1 -1
  145. package/dist/dts/internal/DeferredRef.d.ts +20 -0
  146. package/dist/dts/internal/DeferredRef.d.ts.map +1 -0
  147. package/dist/dts/internal/UnionToTuple.d.ts +6 -0
  148. package/dist/dts/internal/UnionToTuple.d.ts.map +1 -0
  149. package/dist/dts/internal/core.d.ts +218 -450
  150. package/dist/dts/internal/core.d.ts.map +1 -1
  151. package/dist/dts/internal/diff.d.ts +38 -0
  152. package/dist/dts/internal/diff.d.ts.map +1 -0
  153. package/dist/dts/internal/effect-loop-operator.d.ts +34 -0
  154. package/dist/dts/internal/effect-loop-operator.d.ts.map +1 -0
  155. package/dist/dts/internal/effect-operator.d.ts +8 -5
  156. package/dist/dts/internal/effect-operator.d.ts.map +1 -1
  157. package/dist/dts/internal/effect-producer.d.ts +25 -0
  158. package/dist/dts/internal/effect-producer.d.ts.map +1 -0
  159. package/dist/dts/internal/helpers.d.ts +33 -24
  160. package/dist/dts/internal/helpers.d.ts.map +1 -1
  161. package/dist/dts/internal/keyed.d.ts +3 -3
  162. package/dist/dts/internal/keyed.d.ts.map +1 -1
  163. package/dist/dts/internal/loop-operator.d.ts +40 -0
  164. package/dist/dts/internal/loop-operator.d.ts.map +1 -0
  165. package/dist/dts/internal/operator.d.ts +16 -0
  166. package/dist/dts/internal/operator.d.ts.map +1 -0
  167. package/dist/dts/internal/protos.d.ts +16 -43
  168. package/dist/dts/internal/protos.d.ts.map +1 -1
  169. package/dist/dts/internal/provide.d.ts +7 -1
  170. package/dist/dts/internal/provide.d.ts.map +1 -1
  171. package/dist/dts/internal/share.d.ts +12 -9
  172. package/dist/dts/internal/share.d.ts.map +1 -1
  173. package/dist/dts/internal/sync-operator.d.ts +7 -3
  174. package/dist/dts/internal/sync-operator.d.ts.map +1 -1
  175. package/dist/dts/internal/sync-producer.d.ts +36 -0
  176. package/dist/dts/internal/sync-producer.d.ts.map +1 -0
  177. package/dist/dts/internal/withKey.d.ts +3 -3
  178. package/dist/dts/internal/withKey.d.ts.map +1 -1
  179. package/dist/esm/AsyncData.js +151 -0
  180. package/dist/esm/AsyncData.js.map +1 -0
  181. package/dist/esm/Emitter.js +24 -21
  182. package/dist/esm/Emitter.js.map +1 -1
  183. package/dist/esm/Form.js +69 -14
  184. package/dist/esm/Form.js.map +1 -1
  185. package/dist/esm/FormEntry.js +77 -52
  186. package/dist/esm/FormEntry.js.map +1 -1
  187. package/dist/esm/Fx.js +509 -874
  188. package/dist/esm/Fx.js.map +1 -1
  189. package/dist/esm/Guard.js +5 -1
  190. package/dist/esm/Guard.js.map +1 -1
  191. package/dist/esm/Idle.js +49 -39
  192. package/dist/esm/Idle.js.map +1 -1
  193. package/dist/esm/Match.js +103 -63
  194. package/dist/esm/Match.js.map +1 -1
  195. package/dist/esm/Pull.js.map +1 -1
  196. package/dist/esm/Push.js +159 -0
  197. package/dist/esm/Push.js.map +1 -0
  198. package/dist/esm/RefArray.js +32 -30
  199. package/dist/esm/RefArray.js.map +1 -1
  200. package/dist/esm/RefChunk.js +26 -24
  201. package/dist/esm/RefChunk.js.map +1 -1
  202. package/dist/esm/RefHashMap.js +20 -20
  203. package/dist/esm/RefHashMap.js.map +1 -1
  204. package/dist/esm/RefHashSet.js +11 -8
  205. package/dist/esm/RefHashSet.js.map +1 -1
  206. package/dist/esm/RefSubject.js +873 -150
  207. package/dist/esm/RefSubject.js.map +1 -1
  208. package/dist/esm/Sink.js +608 -57
  209. package/dist/esm/Sink.js.map +1 -1
  210. package/dist/esm/Stream.js +13 -9
  211. package/dist/esm/Stream.js.map +1 -1
  212. package/dist/esm/Subject.js +151 -56
  213. package/dist/esm/Subject.js.map +1 -1
  214. package/dist/esm/TypeId.js +9 -4
  215. package/dist/esm/TypeId.js.map +1 -1
  216. package/dist/esm/Typeclass.js +29 -29
  217. package/dist/esm/Typeclass.js.map +1 -1
  218. package/dist/esm/Versioned.js +110 -53
  219. package/dist/esm/Versioned.js.map +1 -1
  220. package/dist/esm/index.js +66 -6
  221. package/dist/esm/index.js.map +1 -1
  222. package/dist/esm/internal/DeferredRef.js +54 -0
  223. package/dist/esm/internal/DeferredRef.js.map +1 -0
  224. package/dist/esm/internal/UnionToTuple.js +2 -0
  225. package/dist/esm/internal/UnionToTuple.js.map +1 -0
  226. package/dist/esm/internal/core.js +1439 -719
  227. package/dist/esm/internal/core.js.map +1 -1
  228. package/dist/esm/internal/diff.js +82 -0
  229. package/dist/esm/internal/diff.js.map +1 -0
  230. package/dist/esm/internal/effect-loop-operator.js +269 -0
  231. package/dist/esm/internal/effect-loop-operator.js.map +1 -0
  232. package/dist/esm/internal/effect-operator.js +44 -37
  233. package/dist/esm/internal/effect-operator.js.map +1 -1
  234. package/dist/esm/internal/effect-producer.js +47 -0
  235. package/dist/esm/internal/effect-producer.js.map +1 -0
  236. package/dist/esm/internal/helpers.js +157 -129
  237. package/dist/esm/internal/helpers.js.map +1 -1
  238. package/dist/esm/internal/keyed.js +128 -139
  239. package/dist/esm/internal/keyed.js.map +1 -1
  240. package/dist/esm/internal/loop-operator.js +186 -0
  241. package/dist/esm/internal/loop-operator.js.map +1 -0
  242. package/dist/esm/internal/operator.js +68 -0
  243. package/dist/esm/internal/operator.js.map +1 -0
  244. package/dist/esm/internal/protos.js +16 -75
  245. package/dist/esm/internal/protos.js.map +1 -1
  246. package/dist/esm/internal/provide.js +33 -25
  247. package/dist/esm/internal/provide.js.map +1 -1
  248. package/dist/esm/internal/requestIdleCallback.js +5 -5
  249. package/dist/esm/internal/requestIdleCallback.js.map +1 -1
  250. package/dist/esm/internal/share.js +12 -12
  251. package/dist/esm/internal/share.js.map +1 -1
  252. package/dist/esm/internal/sync-operator.js +49 -21
  253. package/dist/esm/internal/sync-operator.js.map +1 -1
  254. package/dist/esm/internal/sync-producer.js +88 -0
  255. package/dist/esm/internal/sync-producer.js.map +1 -0
  256. package/dist/esm/internal/withKey.js +46 -47
  257. package/dist/esm/internal/withKey.js.map +1 -1
  258. package/package.json +22 -62
  259. package/src/AsyncData.ts +447 -0
  260. package/src/Emitter.ts +47 -38
  261. package/src/Form.ts +185 -65
  262. package/src/FormEntry.ts +142 -109
  263. package/src/Fx.ts +1685 -1851
  264. package/src/Guard.ts +12 -1
  265. package/src/Idle.ts +76 -62
  266. package/src/Match.ts +149 -93
  267. package/src/Pull.ts +8 -8
  268. package/src/Push.ts +472 -0
  269. package/src/RefArray.ts +53 -51
  270. package/src/RefChunk.ts +44 -41
  271. package/src/RefHashMap.ts +57 -43
  272. package/src/RefHashSet.ts +21 -31
  273. package/src/RefSubject.ts +1984 -457
  274. package/src/Sink.ts +922 -171
  275. package/src/Stream.ts +32 -20
  276. package/src/Subject.ts +230 -87
  277. package/src/TypeId.ts +16 -4
  278. package/src/Typeclass.ts +31 -32
  279. package/src/Versioned.ts +220 -168
  280. package/src/index.ts +78 -6
  281. package/src/internal/DeferredRef.ts +62 -0
  282. package/src/internal/UnionToTuple.ts +11 -0
  283. package/src/internal/core.ts +2491 -1950
  284. package/src/internal/diff.ts +157 -0
  285. package/src/internal/effect-loop-operator.ts +466 -0
  286. package/src/internal/effect-operator.ts +89 -54
  287. package/src/internal/effect-producer.ts +125 -0
  288. package/src/internal/helpers.ts +275 -205
  289. package/src/internal/keyed.ts +192 -241
  290. package/src/internal/loop-operator.ts +266 -0
  291. package/src/internal/operator.ts +87 -0
  292. package/src/internal/protos.ts +29 -104
  293. package/src/internal/provide.ts +48 -40
  294. package/src/internal/requestIdleCallback.ts +5 -6
  295. package/src/internal/share.ts +26 -24
  296. package/src/internal/sync-operator.ts +68 -27
  297. package/src/internal/sync-producer.ts +146 -0
  298. package/src/internal/withKey.ts +64 -74
  299. package/dist/cjs/Computed.js +0 -115
  300. package/dist/cjs/Computed.js.map +0 -1
  301. package/dist/cjs/Filtered.js +0 -95
  302. package/dist/cjs/Filtered.js.map +0 -1
  303. package/dist/cjs/Model.js +0 -119
  304. package/dist/cjs/Model.js.map +0 -1
  305. package/dist/cjs/RefAsyncData.js +0 -187
  306. package/dist/cjs/RefAsyncData.js.map +0 -1
  307. package/dist/cjs/RefAsyncDataArray.js +0 -38
  308. package/dist/cjs/RefAsyncDataArray.js.map +0 -1
  309. package/dist/cjs/RefBoolean.js +0 -45
  310. package/dist/cjs/RefBoolean.js.map +0 -1
  311. package/dist/cjs/RefNumber.js +0 -49
  312. package/dist/cjs/RefNumber.js.map +0 -1
  313. package/dist/cjs/internal/core-ref-subject.js +0 -254
  314. package/dist/cjs/internal/core-ref-subject.js.map +0 -1
  315. package/dist/cjs/internal/core-subject.js +0 -108
  316. package/dist/cjs/internal/core-subject.js.map +0 -1
  317. package/dist/cjs/internal/deferred-ref.js.map +0 -1
  318. package/dist/cjs/internal/effect-primitive.js +0 -47
  319. package/dist/cjs/internal/effect-primitive.js.map +0 -1
  320. package/dist/cjs/internal/fx-effect-proto.js +0 -58
  321. package/dist/cjs/internal/fx-effect-proto.js.map +0 -1
  322. package/dist/cjs/internal/fx-primitive.js +0 -193
  323. package/dist/cjs/internal/fx-primitive.js.map +0 -1
  324. package/dist/cjs/internal/fx.js +0 -240
  325. package/dist/cjs/internal/fx.js.map +0 -1
  326. package/dist/cjs/internal/matchers.js +0 -34
  327. package/dist/cjs/internal/matchers.js.map +0 -1
  328. package/dist/cjs/internal/run.js +0 -54
  329. package/dist/cjs/internal/run.js.map +0 -1
  330. package/dist/cjs/internal/schema-ref-subject.js +0 -132
  331. package/dist/cjs/internal/schema-ref-subject.js.map +0 -1
  332. package/dist/cjs/internal/versioned-transform.js +0 -46
  333. package/dist/cjs/internal/versioned-transform.js.map +0 -1
  334. package/dist/dts/Computed.d.ts +0 -106
  335. package/dist/dts/Computed.d.ts.map +0 -1
  336. package/dist/dts/Filtered.d.ts +0 -97
  337. package/dist/dts/Filtered.d.ts.map +0 -1
  338. package/dist/dts/Model.d.ts +0 -200
  339. package/dist/dts/Model.d.ts.map +0 -1
  340. package/dist/dts/RefAsyncData.d.ts +0 -236
  341. package/dist/dts/RefAsyncData.d.ts.map +0 -1
  342. package/dist/dts/RefAsyncDataArray.d.ts +0 -56
  343. package/dist/dts/RefAsyncDataArray.d.ts.map +0 -1
  344. package/dist/dts/RefBoolean.d.ts +0 -47
  345. package/dist/dts/RefBoolean.d.ts.map +0 -1
  346. package/dist/dts/RefNumber.d.ts +0 -48
  347. package/dist/dts/RefNumber.d.ts.map +0 -1
  348. package/dist/dts/internal/core-ref-subject.d.ts +0 -100
  349. package/dist/dts/internal/core-ref-subject.d.ts.map +0 -1
  350. package/dist/dts/internal/core-subject.d.ts +0 -5
  351. package/dist/dts/internal/core-subject.d.ts.map +0 -1
  352. package/dist/dts/internal/deferred-ref.d.ts +0 -12
  353. package/dist/dts/internal/deferred-ref.d.ts.map +0 -1
  354. package/dist/dts/internal/effect-primitive.d.ts +0 -6
  355. package/dist/dts/internal/effect-primitive.d.ts.map +0 -1
  356. package/dist/dts/internal/fx-effect-proto.d.ts +0 -30
  357. package/dist/dts/internal/fx-effect-proto.d.ts.map +0 -1
  358. package/dist/dts/internal/fx-primitive.d.ts +0 -109
  359. package/dist/dts/internal/fx-primitive.d.ts.map +0 -1
  360. package/dist/dts/internal/fx.d.ts +0 -245
  361. package/dist/dts/internal/fx.d.ts.map +0 -1
  362. package/dist/dts/internal/matchers.d.ts +0 -33
  363. package/dist/dts/internal/matchers.d.ts.map +0 -1
  364. package/dist/dts/internal/run.d.ts +0 -8
  365. package/dist/dts/internal/run.d.ts.map +0 -1
  366. package/dist/dts/internal/schema-ref-subject.d.ts +0 -5
  367. package/dist/dts/internal/schema-ref-subject.d.ts.map +0 -1
  368. package/dist/dts/internal/versioned-transform.d.ts +0 -17
  369. package/dist/dts/internal/versioned-transform.d.ts.map +0 -1
  370. package/dist/esm/Computed.js +0 -103
  371. package/dist/esm/Computed.js.map +0 -1
  372. package/dist/esm/Filtered.js +0 -83
  373. package/dist/esm/Filtered.js.map +0 -1
  374. package/dist/esm/Model.js +0 -100
  375. package/dist/esm/Model.js.map +0 -1
  376. package/dist/esm/RefAsyncData.js +0 -163
  377. package/dist/esm/RefAsyncData.js.map +0 -1
  378. package/dist/esm/RefAsyncDataArray.js +0 -27
  379. package/dist/esm/RefAsyncDataArray.js.map +0 -1
  380. package/dist/esm/RefBoolean.js +0 -31
  381. package/dist/esm/RefBoolean.js.map +0 -1
  382. package/dist/esm/RefNumber.js +0 -35
  383. package/dist/esm/RefNumber.js.map +0 -1
  384. package/dist/esm/internal/core-ref-subject.js +0 -242
  385. package/dist/esm/internal/core-ref-subject.js.map +0 -1
  386. package/dist/esm/internal/core-subject.js +0 -90
  387. package/dist/esm/internal/core-subject.js.map +0 -1
  388. package/dist/esm/internal/deferred-ref.js +0 -23
  389. package/dist/esm/internal/deferred-ref.js.map +0 -1
  390. package/dist/esm/internal/effect-primitive.js +0 -41
  391. package/dist/esm/internal/effect-primitive.js.map +0 -1
  392. package/dist/esm/internal/fx-effect-proto.js +0 -43
  393. package/dist/esm/internal/fx-effect-proto.js.map +0 -1
  394. package/dist/esm/internal/fx-primitive.js +0 -175
  395. package/dist/esm/internal/fx-primitive.js.map +0 -1
  396. package/dist/esm/internal/fx.js +0 -216
  397. package/dist/esm/internal/fx.js.map +0 -1
  398. package/dist/esm/internal/matchers.js +0 -38
  399. package/dist/esm/internal/matchers.js.map +0 -1
  400. package/dist/esm/internal/run.js +0 -32
  401. package/dist/esm/internal/run.js.map +0 -1
  402. package/dist/esm/internal/schema-ref-subject.js +0 -121
  403. package/dist/esm/internal/schema-ref-subject.js.map +0 -1
  404. package/dist/esm/internal/versioned-transform.js +0 -37
  405. package/dist/esm/internal/versioned-transform.js.map +0 -1
  406. package/src/Computed.ts +0 -289
  407. package/src/Filtered.ts +0 -274
  408. package/src/Model.ts +0 -483
  409. package/src/RefAsyncData.ts +0 -547
  410. package/src/RefAsyncDataArray.ts +0 -135
  411. package/src/RefBoolean.ts +0 -71
  412. package/src/RefNumber.ts +0 -77
  413. package/src/internal/core-ref-subject.ts +0 -528
  414. package/src/internal/core-subject.ts +0 -143
  415. package/src/internal/deferred-ref.ts +0 -26
  416. package/src/internal/effect-primitive.ts +0 -230
  417. package/src/internal/fx-effect-proto.ts +0 -56
  418. package/src/internal/fx-primitive.ts +0 -223
  419. package/src/internal/fx.ts +0 -619
  420. package/src/internal/matchers.ts +0 -83
  421. package/src/internal/run.ts +0 -51
  422. package/src/internal/schema-ref-subject.ts +0 -163
  423. package/src/internal/versioned-transform.ts +0 -48
package/dist/cjs/Sink.js CHANGED
@@ -3,53 +3,57 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Sink = Sink;
7
- exports.WithContext = WithContext;
8
- exports.mapErrorEffect = exports.mapErrorCauseEffect = exports.mapErrorCause = exports.mapError = exports.mapEffect = exports.map = void 0;
9
- exports.provide = provide;
10
- exports.setSpan = void 0;
6
+ exports.dropWhileEffect = exports.dropWhile = exports.dropAfterEffect = exports.dropAfter = void 0;
7
+ exports.filter = filter;
8
+ exports.filterEffect = void 0;
9
+ exports.filterMap = filterMap;
10
+ exports.filterMapLoopCause = exports.filterMapLoop = exports.filterMapEffect = void 0;
11
+ exports.filterMapLoopCauseEffect = filterMapLoopCauseEffect;
12
+ exports.fromTag = exports.filterMapLoopEffect = void 0;
13
+ exports.ignoreInterrupt = ignoreInterrupt;
14
+ exports.loopEffect = exports.loopCauseEffect = exports.loopCause = exports.loop = void 0;
15
+ exports.make = make;
16
+ exports.slice = exports.setSpan = exports.provide = exports.mapEffect = exports.map = void 0;
17
+ exports.tagged = tagged;
18
+ exports.tapEffect = exports.takeWhileEffect = exports.takeWhile = void 0;
19
+ exports.withEarlyExit = withEarlyExit;
20
+ var C = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@typed/context"));
11
21
  var Cause = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Cause"));
12
22
  var Clock = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Clock"));
13
23
  var Effect = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Effect"));
14
- var Either = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Either"));
15
24
  var _Function = /*#__PURE__*/require("effect/Function");
25
+ var Layer = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Layer"));
26
+ var Option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Option"));
16
27
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
28
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
29
  /**
19
- * Sink is a data structure that represents a place to send failures and successes
20
- * over time in an effectful manner.
21
- * @since 1.18.0
30
+ * Sink is a data structure which can be used to consume values from a stream.
31
+ * @since 1.20.0
22
32
  */
23
33
 
24
34
  /**
25
- * Construct a Sink that can be used to handle failures and successes.
26
- * @since 1.18.0
27
- * @category constructors
35
+ * @since 1.20.0
28
36
  */
29
- function Sink(onFailure, onSuccess) {
37
+ function make(onFailure, onSuccess) {
30
38
  return {
31
39
  onFailure,
32
40
  onSuccess
33
41
  };
34
42
  }
35
43
  /**
36
- * Construct a Sink that can be used to handle failures and successes with a Context.
37
- * @since 1.18.0
38
- * @category constructors
44
+ * @since 1.20.0
39
45
  */
40
- function WithContext(onFailure, onSuccess) {
41
- return {
42
- onFailure,
43
- onSuccess
44
- };
45
- }
46
- /**
47
- * Provide a Context to a Sink
48
- * @since 1.18.0
49
- * @category context
50
- */
51
- function provide(sink, ctx) {
52
- return Sink(cause => Effect.provide(sink.onFailure(cause), ctx), a => Effect.provide(sink.onSuccess(a), ctx));
46
+ function withEarlyExit(sink, f) {
47
+ return Effect.asyncEffect(resume => {
48
+ const earlyExit = {
49
+ ...sink,
50
+ earlyExit: Effect.sync(() => resume(Effect.unit))
51
+ };
52
+ return Effect.matchCauseEffect(f(earlyExit), {
53
+ onFailure: cause => sink.onFailure(cause),
54
+ onSuccess: () => earlyExit.earlyExit
55
+ });
56
+ });
53
57
  }
54
58
  /**
55
59
  * Transform the input value of a Sink.
@@ -57,58 +61,533 @@ function provide(sink, ctx) {
57
61
  * @category combinators
58
62
  */
59
63
  const map = exports.map = /*#__PURE__*/(0, _Function.dual)(2, function map(sink, f) {
60
- return WithContext(sink.onFailure, a => sink.onSuccess(f(a)));
64
+ return new MapSink(sink, f);
61
65
  });
66
+ class MapSink {
67
+ sink;
68
+ f;
69
+ constructor(sink, f) {
70
+ this.sink = sink;
71
+ this.f = f;
72
+ this.onFailure = this.onFailure.bind(this);
73
+ this.onSuccess = this.onSuccess.bind(this);
74
+ }
75
+ onFailure(cause) {
76
+ return this.sink.onFailure(cause);
77
+ }
78
+ onSuccess(value) {
79
+ return this.sink.onSuccess(this.f(value));
80
+ }
81
+ }
62
82
  /**
63
- * Transform the input value of a Sink using an Effect.
64
- * @since 1.18.0
65
- * @category combinators
83
+ * @since 1.20.0
84
+ */
85
+ function filter(sink, predicate) {
86
+ return new FilterSink(sink, predicate);
87
+ }
88
+ class FilterSink {
89
+ sink;
90
+ predicate;
91
+ constructor(sink, predicate) {
92
+ this.sink = sink;
93
+ this.predicate = predicate;
94
+ this.onFailure = this.onFailure.bind(this);
95
+ this.onSuccess = this.onSuccess.bind(this);
96
+ }
97
+ onFailure(cause) {
98
+ return this.sink.onFailure(cause);
99
+ }
100
+ onSuccess(value) {
101
+ if (this.predicate(value)) return this.sink.onSuccess(value);else return Effect.unit;
102
+ }
103
+ }
104
+ /**
105
+ * @since 1.20.0
106
+ */
107
+ function filterMap(sink, f) {
108
+ return new FilterMapSink(sink, f);
109
+ }
110
+ class FilterMapSink {
111
+ sink;
112
+ f;
113
+ constructor(sink, f) {
114
+ this.sink = sink;
115
+ this.f = f;
116
+ this.onFailure = this.onFailure.bind(this);
117
+ this.onSuccess = this.onSuccess.bind(this);
118
+ }
119
+ onFailure(cause) {
120
+ return this.sink.onFailure(cause);
121
+ }
122
+ onSuccess(value) {
123
+ const option = this.f(value);
124
+ if (Option.isSome(option)) return this.sink.onSuccess(option.value);else return Effect.unit;
125
+ }
126
+ }
127
+ /**
128
+ * @since 1.20.0
66
129
  */
67
130
  const mapEffect = exports.mapEffect = /*#__PURE__*/(0, _Function.dual)(2, function mapEffect(sink, f) {
68
- return WithContext(sink.onFailure, b => Effect.matchCauseEffect(f(b), sink));
131
+ return new MapEffectSink(sink, f);
69
132
  });
133
+ class MapEffectSink {
134
+ sink;
135
+ f;
136
+ constructor(sink, f) {
137
+ this.sink = sink;
138
+ this.f = f;
139
+ this.onFailure = this.onFailure.bind(this);
140
+ this.onSuccess = this.onSuccess.bind(this);
141
+ }
142
+ onFailure(cause) {
143
+ return this.sink.onFailure(cause);
144
+ }
145
+ onSuccess(value) {
146
+ return Effect.matchCauseEffect(this.f(value), this.sink);
147
+ }
148
+ }
70
149
  /**
71
- * Transform the input Cause of a Sink.
72
- * @since 1.18.0
73
- * @category combinators
150
+ * @since 1.20.0
151
+ */
152
+ const filterMapEffect = exports.filterMapEffect = /*#__PURE__*/(0, _Function.dual)(2, function filterMapEffect(sink, f) {
153
+ return new FilterMapEffectSink(sink, f);
154
+ });
155
+ class FilterMapEffectSink {
156
+ sink;
157
+ f;
158
+ constructor(sink, f) {
159
+ this.sink = sink;
160
+ this.f = f;
161
+ this.onFailure = this.onFailure.bind(this);
162
+ this.onSuccess = this.onSuccess.bind(this);
163
+ }
164
+ onFailure(cause) {
165
+ return this.sink.onFailure(cause);
166
+ }
167
+ onSuccess(value) {
168
+ return Effect.matchCauseEffect(this.f(value), {
169
+ onFailure: cause => this.sink.onFailure(cause),
170
+ onSuccess: option => {
171
+ if (Option.isSome(option)) return this.sink.onSuccess(option.value);else return Effect.unit;
172
+ }
173
+ });
174
+ }
175
+ }
176
+ /**
177
+ * @since 1.20.0
74
178
  */
75
- const mapErrorCause = exports.mapErrorCause = /*#__PURE__*/(0, _Function.dual)(2, function mapErrorCause(sink, f) {
76
- return Sink(cause => sink.onFailure(f(cause)), sink.onSuccess);
179
+ const filterEffect = exports.filterEffect = /*#__PURE__*/(0, _Function.dual)(2, function filterEffect(sink, f) {
180
+ return new FilterEffectSink(sink, f);
77
181
  });
182
+ class FilterEffectSink {
183
+ sink;
184
+ f;
185
+ constructor(sink, f) {
186
+ this.sink = sink;
187
+ this.f = f;
188
+ this.onFailure = this.onFailure.bind(this);
189
+ this.onSuccess = this.onSuccess.bind(this);
190
+ }
191
+ onFailure(cause) {
192
+ return this.sink.onFailure(cause);
193
+ }
194
+ onSuccess(value) {
195
+ return Effect.matchCauseEffect(this.f(value), {
196
+ onFailure: cause => this.sink.onFailure(cause),
197
+ onSuccess: b => {
198
+ if (b) return this.sink.onSuccess(value);else return Effect.unit;
199
+ }
200
+ });
201
+ }
202
+ }
78
203
  /**
79
- * Transform the input Cause of a Sink using an Effect.
80
- * @since 1.18.0
81
- * @category combinators
204
+ * @since 1.20.0
82
205
  */
83
- const mapErrorCauseEffect = exports.mapErrorCauseEffect = /*#__PURE__*/(0, _Function.dual)(2, function mapErrorCauseEffect(sink, f) {
84
- return WithContext(cause => Effect.matchCauseEffect(f(cause), WithContext(sink.onFailure, sink.onFailure)), sink.onSuccess);
206
+ const tapEffect = exports.tapEffect = /*#__PURE__*/(0, _Function.dual)(2, function tapEffect(sink, f) {
207
+ return new TapEffectSink(sink, f);
85
208
  });
209
+ class TapEffectSink {
210
+ sink;
211
+ f;
212
+ constructor(sink, f) {
213
+ this.sink = sink;
214
+ this.f = f;
215
+ this.onFailure = this.onFailure.bind(this);
216
+ this.onSuccess = this.onSuccess.bind(this);
217
+ }
218
+ onFailure(cause) {
219
+ return this.sink.onFailure(cause);
220
+ }
221
+ onSuccess(value) {
222
+ return Effect.matchCauseEffect(this.f(value), {
223
+ onFailure: cause => this.sink.onFailure(cause),
224
+ onSuccess: () => this.sink.onSuccess(value)
225
+ });
226
+ }
227
+ }
86
228
  /**
87
- * Transform the input Error of a Sink.
88
- * @since 1.18.0
89
- * @category combinators
229
+ * @since 1.20.0
90
230
  */
91
- const mapError = exports.mapError = /*#__PURE__*/(0, _Function.dual)(2, function mapError(sink, f) {
92
- return WithContext(cause => sink.onFailure(Cause.map(cause, f)), sink.onSuccess);
231
+ const loop = exports.loop = /*#__PURE__*/(0, _Function.dual)(3, function loop(sink, seed, f) {
232
+ return new LoopSink(sink, seed, f);
93
233
  });
234
+ class LoopSink {
235
+ sink;
236
+ seed;
237
+ f;
238
+ constructor(sink, seed, f) {
239
+ this.sink = sink;
240
+ this.seed = seed;
241
+ this.f = f;
242
+ this.onFailure = this.onFailure.bind(this);
243
+ this.onSuccess = this.onSuccess.bind(this);
244
+ }
245
+ onFailure(cause) {
246
+ return this.sink.onFailure(cause);
247
+ }
248
+ onSuccess(value) {
249
+ const [c, acc] = this.f(this.seed, value);
250
+ this.seed = acc;
251
+ return this.sink.onSuccess(c);
252
+ }
253
+ }
94
254
  /**
95
- * Transform the input Error of a Sink using an Effect.
96
- * @since 1.18.0
97
- * @category combinators
255
+ * @since 1.20.0
98
256
  */
99
- const mapErrorEffect = exports.mapErrorEffect = /*#__PURE__*/(0, _Function.dual)(2, function mapErrorEffect(sink, f) {
100
- return mapErrorCauseEffect(sink, cause => Either.match(Cause.failureOrCause(cause), {
101
- onLeft: e2 => Effect.map(f(e2), Cause.fail),
102
- onRight: cause => Effect.succeed(cause)
103
- }));
257
+ const loopCause = exports.loopCause = /*#__PURE__*/(0, _Function.dual)(3, function loopCause(sink, seed, f) {
258
+ return new LoopCauseSink(sink, seed, f);
104
259
  });
260
+ class LoopCauseSink {
261
+ sink;
262
+ seed;
263
+ f;
264
+ constructor(sink, seed, f) {
265
+ this.sink = sink;
266
+ this.seed = seed;
267
+ this.f = f;
268
+ this.onFailure = this.onFailure.bind(this);
269
+ this.onSuccess = this.onSuccess.bind(this);
270
+ }
271
+ onFailure(cause) {
272
+ const [c, acc] = this.f(this.seed, cause);
273
+ this.seed = acc;
274
+ return this.sink.onFailure(c);
275
+ }
276
+ onSuccess(value) {
277
+ return this.sink.onSuccess(value);
278
+ }
279
+ }
105
280
  /**
106
- * Set the span a Sink will use to append events to.
107
- * @since 1.18.0
108
- * @category tracing
281
+ * @since 1.20.0
109
282
  */
110
- const setSpan = exports.setSpan = /*#__PURE__*/(0, _Function.dual)(2, function withSpan(self, span) {
111
- return WithContext(cause => addEvent(self.onFailure(cause), "fx.failure", span, {
283
+ const filterMapLoop = exports.filterMapLoop = /*#__PURE__*/(0, _Function.dual)(3, function filterMapLoop(sink, seed, f) {
284
+ return new FilterMapLoopSink(sink, seed, f);
285
+ });
286
+ class FilterMapLoopSink {
287
+ sink;
288
+ seed;
289
+ f;
290
+ constructor(sink, seed, f) {
291
+ this.sink = sink;
292
+ this.seed = seed;
293
+ this.f = f;
294
+ this.onFailure = this.onFailure.bind(this);
295
+ this.onSuccess = this.onSuccess.bind(this);
296
+ }
297
+ onFailure(cause) {
298
+ return this.sink.onFailure(cause);
299
+ }
300
+ onSuccess(value) {
301
+ const [option, acc] = this.f(this.seed, value);
302
+ this.seed = acc;
303
+ if (Option.isSome(option)) return this.sink.onSuccess(option.value);else return Effect.unit;
304
+ }
305
+ }
306
+ /**
307
+ * @since 1.20.0
308
+ */
309
+ const filterMapLoopCause = exports.filterMapLoopCause = /*#__PURE__*/(0, _Function.dual)(3, function filterMapLoopCause(sink, seed, f) {
310
+ return new FilterMapLoopCauseSink(sink, seed, f);
311
+ });
312
+ class FilterMapLoopCauseSink {
313
+ sink;
314
+ seed;
315
+ f;
316
+ constructor(sink, seed, f) {
317
+ this.sink = sink;
318
+ this.seed = seed;
319
+ this.f = f;
320
+ this.onFailure = this.onFailure.bind(this);
321
+ this.onSuccess = this.onSuccess.bind(this);
322
+ }
323
+ onFailure(cause) {
324
+ const [option, acc] = this.f(this.seed, cause);
325
+ this.seed = acc;
326
+ if (Option.isSome(option)) return this.sink.onFailure(option.value);else return Effect.unit;
327
+ }
328
+ onSuccess(value) {
329
+ return this.sink.onSuccess(value);
330
+ }
331
+ }
332
+ /**
333
+ * @since 1.20.0
334
+ */
335
+ const loopEffect = exports.loopEffect = /*#__PURE__*/(0, _Function.dual)(3, function loopEffect(sink, seed, f) {
336
+ return new LoopEffectSink(sink, seed, f);
337
+ });
338
+ class LoopEffectSink {
339
+ sink;
340
+ seed;
341
+ f;
342
+ constructor(sink, seed, f) {
343
+ this.sink = sink;
344
+ this.seed = seed;
345
+ this.f = f;
346
+ this.onFailure = this.onFailure.bind(this);
347
+ this.onSuccess = this.onSuccess.bind(this);
348
+ }
349
+ onFailure(cause) {
350
+ return this.sink.onFailure(cause);
351
+ }
352
+ onSuccess(value) {
353
+ return Effect.matchCauseEffect(this.f(this.seed, value), {
354
+ onFailure: cause => this.sink.onFailure(cause),
355
+ onSuccess: ([c, acc]) => {
356
+ this.seed = acc;
357
+ return this.sink.onSuccess(c);
358
+ }
359
+ });
360
+ }
361
+ }
362
+ /**
363
+ * @since 1.20.0
364
+ */
365
+ const filterMapLoopEffect = exports.filterMapLoopEffect = /*#__PURE__*/(0, _Function.dual)(3, function filterMapLoopEffect(sink, seed, f) {
366
+ return new FilterMapLoopEffectSink(sink, seed, f);
367
+ });
368
+ class FilterMapLoopEffectSink {
369
+ sink;
370
+ seed;
371
+ f;
372
+ constructor(sink, seed, f) {
373
+ this.sink = sink;
374
+ this.seed = seed;
375
+ this.f = f;
376
+ this.onFailure = this.onFailure.bind(this);
377
+ this.onSuccess = this.onSuccess.bind(this);
378
+ }
379
+ onFailure(cause) {
380
+ return this.sink.onFailure(cause);
381
+ }
382
+ onSuccess(value) {
383
+ return Effect.matchCauseEffect(this.f(this.seed, value), {
384
+ onFailure: cause => this.sink.onFailure(cause),
385
+ onSuccess: ([option, acc]) => {
386
+ this.seed = acc;
387
+ if (Option.isSome(option)) return this.sink.onSuccess(option.value);else return Effect.unit;
388
+ }
389
+ });
390
+ }
391
+ }
392
+ /**
393
+ * @since 1.20.0
394
+ */
395
+ const loopCauseEffect = exports.loopCauseEffect = /*#__PURE__*/(0, _Function.dual)(3, function loopCauseEffect(sink, seed, f) {
396
+ return new LoopCauseEffectSink(sink, seed, f);
397
+ });
398
+ class LoopCauseEffectSink {
399
+ sink;
400
+ seed;
401
+ f;
402
+ constructor(sink, seed, f) {
403
+ this.sink = sink;
404
+ this.seed = seed;
405
+ this.f = f;
406
+ this.onFailure = this.onFailure.bind(this);
407
+ this.onSuccess = this.onSuccess.bind(this);
408
+ }
409
+ onFailure(cause) {
410
+ return Effect.matchCauseEffect(this.f(this.seed, cause), {
411
+ onFailure: cause2 => this.sink.onFailure(Cause.sequential(cause, cause2)),
412
+ onSuccess: ([c, acc]) => {
413
+ this.seed = acc;
414
+ return this.sink.onFailure(c);
415
+ }
416
+ });
417
+ }
418
+ onSuccess(value) {
419
+ return this.sink.onSuccess(value);
420
+ }
421
+ }
422
+ /**
423
+ * @since 1.20.0
424
+ */
425
+ function filterMapLoopCauseEffect(sink, seed, f) {
426
+ return new FilterMapLoopCauseEffectSink(sink, seed, f);
427
+ }
428
+ class FilterMapLoopCauseEffectSink {
429
+ sink;
430
+ seed;
431
+ f;
432
+ constructor(sink, seed, f) {
433
+ this.sink = sink;
434
+ this.seed = seed;
435
+ this.f = f;
436
+ this.onFailure = this.onFailure.bind(this);
437
+ this.onSuccess = this.onSuccess.bind(this);
438
+ }
439
+ onFailure(cause) {
440
+ return Effect.matchCauseEffect(this.f(this.seed, cause), {
441
+ onFailure: cause2 => this.sink.onFailure(cause2),
442
+ onSuccess: ([option, acc]) => {
443
+ this.seed = acc;
444
+ if (Option.isSome(option)) return this.sink.onFailure(option.value);else return Effect.unit;
445
+ }
446
+ });
447
+ }
448
+ onSuccess(value) {
449
+ return this.sink.onSuccess(value);
450
+ }
451
+ }
452
+ /**
453
+ * @since 1.20.0
454
+ */
455
+ const slice = exports.slice = /*#__PURE__*/(0, _Function.dual)(3, function slice(sink, bounds, f) {
456
+ return withEarlyExit(sink, s => f(new SliceSink(s, bounds)));
457
+ });
458
+ class SliceSink {
459
+ sink;
460
+ bounds;
461
+ drop;
462
+ take;
463
+ constructor(sink, bounds) {
464
+ this.sink = sink;
465
+ this.bounds = bounds;
466
+ this.drop = this.bounds.min;
467
+ this.take = this.bounds.max;
468
+ this.onFailure = this.onFailure.bind(this);
469
+ this.onSuccess = this.onSuccess.bind(this);
470
+ }
471
+ onFailure(cause) {
472
+ return this.sink.onFailure(cause);
473
+ }
474
+ onSuccess(value) {
475
+ if (this.drop > 0) {
476
+ this.drop--;
477
+ return Effect.unit;
478
+ }
479
+ if (this.take-- > 0) {
480
+ return Effect.tap(this.sink.onSuccess(value), () => this.take === 0 ? this.sink.earlyExit : Effect.unit);
481
+ }
482
+ return this.sink.earlyExit;
483
+ }
484
+ }
485
+ /**
486
+ * @since 1.20.0
487
+ */
488
+ const takeWhile = exports.takeWhile = /*#__PURE__*/(0, _Function.dual)(3, function takeWhile(sink, predicate, f) {
489
+ return withEarlyExit(sink, s => f(new TakeWhileSink(s, predicate)));
490
+ });
491
+ class TakeWhileSink {
492
+ sink;
493
+ predicate;
494
+ take;
495
+ constructor(sink, predicate) {
496
+ this.sink = sink;
497
+ this.predicate = predicate;
498
+ this.take = true;
499
+ this.onFailure = this.onFailure.bind(this);
500
+ this.onSuccess = this.onSuccess.bind(this);
501
+ }
502
+ onFailure(cause) {
503
+ return this.sink.onFailure(cause);
504
+ }
505
+ onSuccess(value) {
506
+ if (this.take === true && (this.take = this.predicate(value))) return this.sink.onSuccess(value);else {
507
+ this.take = false;
508
+ return this.sink.earlyExit;
509
+ }
510
+ }
511
+ }
512
+ /**
513
+ * @since 1.20.0
514
+ */
515
+ const dropWhile = exports.dropWhile = /*#__PURE__*/(0, _Function.dual)(2, function dropWhile(sink, predicate) {
516
+ return filterMapLoop(sink, true, (drop, a) => {
517
+ const drop2 = drop && predicate(a);
518
+ return [drop2 ? Option.none() : Option.some(a), drop2];
519
+ });
520
+ });
521
+ /**
522
+ * @since 1.20.0
523
+ */
524
+ const dropAfter = exports.dropAfter = /*#__PURE__*/(0, _Function.dual)(2, function dropAfter(sink, predicate) {
525
+ return filterMapLoop(sink, false, (drop, a) => {
526
+ if (drop === true) return [Option.none(), drop];
527
+ const drop2 = predicate(a);
528
+ return [Option.some(a), drop2];
529
+ });
530
+ });
531
+ /**
532
+ * @since 1.20.0
533
+ */
534
+ const takeWhileEffect = exports.takeWhileEffect = /*#__PURE__*/(0, _Function.dual)(3, function takeWhileEffect(sink, predicate, f) {
535
+ return withEarlyExit(sink, s => f(new TakeWhileEffectSink(s, predicate)));
536
+ });
537
+ class TakeWhileEffectSink {
538
+ sink;
539
+ predicate;
540
+ take;
541
+ constructor(sink, predicate) {
542
+ this.sink = sink;
543
+ this.predicate = predicate;
544
+ this.take = true;
545
+ this.onFailure = this.onFailure.bind(this);
546
+ this.onSuccess = this.onSuccess.bind(this);
547
+ }
548
+ onFailure(cause) {
549
+ return this.sink.onFailure(cause);
550
+ }
551
+ onSuccess(value) {
552
+ if (this.take === true) {
553
+ return Effect.matchCauseEffect(this.predicate(value), {
554
+ onFailure: cause => this.sink.onFailure(cause),
555
+ onSuccess: b => {
556
+ if (this.take = b) return this.sink.onSuccess(value);else return this.sink.earlyExit;
557
+ }
558
+ });
559
+ } else return this.sink.earlyExit;
560
+ }
561
+ }
562
+ /**
563
+ * @since 1.20.0
564
+ */
565
+ const dropWhileEffect = exports.dropWhileEffect = /*#__PURE__*/(0, _Function.dual)(2, function dropWhileEffect(sink, predicate) {
566
+ return filterMapLoopEffect(sink, true, (drop, a) => {
567
+ if (drop === false) return Effect.succeed([Option.some(a), drop]);
568
+ return Effect.map(predicate(a), b => [b ? Option.none() : Option.some(a), b]);
569
+ });
570
+ });
571
+ /**
572
+ * @since 1.20.0
573
+ */
574
+ const dropAfterEffect = exports.dropAfterEffect = /*#__PURE__*/(0, _Function.dual)(2, function dropAfterEffect(sink, predicate) {
575
+ return filterMapLoopEffect(sink, false, (drop, a) => {
576
+ if (drop === true) return Effect.succeed([Option.none(), drop]);
577
+ return Effect.map(predicate(a), b => [Option.some(a), b]);
578
+ });
579
+ });
580
+ /**
581
+ * @since 1.20.0
582
+ */
583
+ const provide = exports.provide = /*#__PURE__*/(0, _Function.dual)(2, function provide(sink, ctx) {
584
+ return make(cause => Effect.provide(sink.onFailure(cause), ctx), a => Effect.provide(sink.onSuccess(a), ctx));
585
+ });
586
+ /**
587
+ * @since 1.20.0
588
+ */
589
+ const setSpan = exports.setSpan = /*#__PURE__*/(0, _Function.dual)(2, function setSpan(self, span) {
590
+ return make(cause => addEvent(self.onFailure(cause), "fx.failure", span, {
112
591
  "cause": Cause.pretty(cause)
113
592
  }), a => addEvent(self.onSuccess(a), "fx.success", span, {
114
593
  "value": JSON.stringify(a)
@@ -118,4 +597,51 @@ const addEvent = (effect, name, span, attributes) => Effect.flatMap(Clock.curren
118
597
  span.event(name, time, attributes);
119
598
  return effect;
120
599
  }));
600
+ /**
601
+ * @since 1.20.0
602
+ */
603
+ function tagged() {
604
+ return identifier => new TaggedImpl(C.Tagged(identifier));
605
+ }
606
+ class TaggedImpl {
607
+ tag;
608
+ constructor(tag) {
609
+ this.tag = tag;
610
+ }
611
+ onSuccess(value) {
612
+ return this.tag.withEffect(sink => sink.onSuccess(value));
613
+ }
614
+ onFailure(cause) {
615
+ return this.tag.withEffect(sink => sink.onFailure(cause));
616
+ }
617
+ make = sink => Layer.flatMap(Layer.context(), ctx => this.tag.layer(provide(sink, ctx)));
618
+ }
619
+ /**
620
+ * @since 1.20.0
621
+ */
622
+ const fromTag = exports.fromTag = /*#__PURE__*/(0, _Function.dual)(2, function fromTag(tag, f) {
623
+ return new FromTag(tag, f);
624
+ });
625
+ class FromTag {
626
+ tag;
627
+ f;
628
+ get;
629
+ constructor(tag, f) {
630
+ this.tag = tag;
631
+ this.f = f;
632
+ this.get = Effect.map(tag, f);
633
+ }
634
+ onSuccess(value) {
635
+ return Effect.flatMap(this.get, sink => sink.onSuccess(value));
636
+ }
637
+ onFailure(cause) {
638
+ return Effect.flatMap(this.get, sink => sink.onFailure(cause));
639
+ }
640
+ }
641
+ /**
642
+ * @since 1.20.0
643
+ */
644
+ function ignoreInterrupt(sink) {
645
+ return make(cause => Cause.isInterruptedOnly(cause) ? Effect.unit : sink.onFailure(cause), sink.onSuccess);
646
+ }
121
647
  //# sourceMappingURL=Sink.js.map