effect 4.0.0-beta.4 → 4.0.0-beta.6

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 (310) hide show
  1. package/dist/Cause.d.ts +1 -1
  2. package/dist/Cause.d.ts.map +1 -1
  3. package/dist/Channel.d.ts.map +1 -1
  4. package/dist/Channel.js +6 -4
  5. package/dist/Channel.js.map +1 -1
  6. package/dist/Config.d.ts +1 -1
  7. package/dist/Data.d.ts +3 -2
  8. package/dist/Data.d.ts.map +1 -1
  9. package/dist/Data.js +9 -8
  10. package/dist/Data.js.map +1 -1
  11. package/dist/Effect.d.ts +0 -226
  12. package/dist/Effect.d.ts.map +1 -1
  13. package/dist/Effect.js +0 -118
  14. package/dist/Effect.js.map +1 -1
  15. package/dist/Encoding.d.ts +194 -0
  16. package/dist/Encoding.d.ts.map +1 -0
  17. package/dist/Encoding.js +352 -0
  18. package/dist/Encoding.js.map +1 -0
  19. package/dist/Equal.js.map +1 -1
  20. package/dist/FileSystem.d.ts +1 -1
  21. package/dist/FileSystem.d.ts.map +1 -1
  22. package/dist/FileSystem.js +5 -5
  23. package/dist/FileSystem.js.map +1 -1
  24. package/dist/Filter.d.ts +30 -1
  25. package/dist/Filter.d.ts.map +1 -1
  26. package/dist/Filter.js +15 -0
  27. package/dist/Filter.js.map +1 -1
  28. package/dist/Formatter.js +1 -1
  29. package/dist/Formatter.js.map +1 -1
  30. package/dist/Graph.d.ts.map +1 -1
  31. package/dist/Graph.js +2 -2
  32. package/dist/Graph.js.map +1 -1
  33. package/dist/Latch.d.ts +109 -0
  34. package/dist/Latch.d.ts.map +1 -0
  35. package/dist/Latch.js +72 -0
  36. package/dist/Latch.js.map +1 -0
  37. package/dist/Pipeable.d.ts +17 -0
  38. package/dist/Pipeable.d.ts.map +1 -1
  39. package/dist/Pipeable.js +19 -1
  40. package/dist/Pipeable.js.map +1 -1
  41. package/dist/PlatformError.d.ts +8 -7
  42. package/dist/PlatformError.d.ts.map +1 -1
  43. package/dist/PlatformError.js +2 -2
  44. package/dist/PlatformError.js.map +1 -1
  45. package/dist/Pool.d.ts +5 -3
  46. package/dist/Pool.d.ts.map +1 -1
  47. package/dist/Pool.js +6 -4
  48. package/dist/Pool.js.map +1 -1
  49. package/dist/PubSub.d.ts +3 -2
  50. package/dist/PubSub.d.ts.map +1 -1
  51. package/dist/PubSub.js +3 -2
  52. package/dist/PubSub.js.map +1 -1
  53. package/dist/Request.d.ts +1 -1
  54. package/dist/Request.d.ts.map +1 -1
  55. package/dist/Request.js +2 -1
  56. package/dist/Request.js.map +1 -1
  57. package/dist/RequestResolver.d.ts +0 -20
  58. package/dist/RequestResolver.d.ts.map +1 -1
  59. package/dist/RequestResolver.js +0 -20
  60. package/dist/RequestResolver.js.map +1 -1
  61. package/dist/Schedule.d.ts +2 -2
  62. package/dist/Schedule.d.ts.map +1 -1
  63. package/dist/Schedule.js +30 -16
  64. package/dist/Schedule.js.map +1 -1
  65. package/dist/Schema.d.ts +192 -42
  66. package/dist/Schema.d.ts.map +1 -1
  67. package/dist/Schema.js +385 -71
  68. package/dist/Schema.js.map +1 -1
  69. package/dist/SchemaGetter.d.ts +2 -2
  70. package/dist/SchemaGetter.d.ts.map +1 -1
  71. package/dist/SchemaGetter.js +12 -14
  72. package/dist/SchemaGetter.js.map +1 -1
  73. package/dist/SchemaRepresentation.d.ts +44 -43
  74. package/dist/SchemaRepresentation.d.ts.map +1 -1
  75. package/dist/SchemaRepresentation.js +5 -2
  76. package/dist/SchemaRepresentation.js.map +1 -1
  77. package/dist/SchemaTransformation.d.ts +37 -0
  78. package/dist/SchemaTransformation.d.ts.map +1 -1
  79. package/dist/SchemaTransformation.js +80 -0
  80. package/dist/SchemaTransformation.js.map +1 -1
  81. package/dist/Semaphore.d.ts +211 -0
  82. package/dist/Semaphore.d.ts.map +1 -0
  83. package/dist/{PartitionedSemaphore.js → Semaphore.js} +97 -13
  84. package/dist/Semaphore.js.map +1 -0
  85. package/dist/Stream.d.ts.map +1 -1
  86. package/dist/Stream.js +9 -8
  87. package/dist/Stream.js.map +1 -1
  88. package/dist/Struct.d.ts +16 -0
  89. package/dist/Struct.d.ts.map +1 -1
  90. package/dist/Struct.js +22 -0
  91. package/dist/Struct.js.map +1 -1
  92. package/dist/SubscriptionRef.d.ts +2 -1
  93. package/dist/SubscriptionRef.d.ts.map +1 -1
  94. package/dist/SubscriptionRef.js +2 -1
  95. package/dist/SubscriptionRef.js.map +1 -1
  96. package/dist/SynchronizedRef.d.ts +2 -1
  97. package/dist/SynchronizedRef.d.ts.map +1 -1
  98. package/dist/SynchronizedRef.js +2 -1
  99. package/dist/SynchronizedRef.js.map +1 -1
  100. package/dist/Types.d.ts +14 -6
  101. package/dist/Types.d.ts.map +1 -1
  102. package/dist/index.d.ts +14 -5
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +14 -5
  105. package/dist/index.js.map +1 -1
  106. package/dist/internal/core.js +11 -3
  107. package/dist/internal/core.js.map +1 -1
  108. package/dist/internal/effect.js.map +1 -1
  109. package/dist/internal/rcRef.js +2 -1
  110. package/dist/internal/rcRef.js.map +1 -1
  111. package/dist/testing/TestClock.d.ts +3 -2
  112. package/dist/testing/TestClock.d.ts.map +1 -1
  113. package/dist/testing/TestClock.js +5 -3
  114. package/dist/testing/TestClock.js.map +1 -1
  115. package/dist/unstable/ai/AiError.d.ts +39 -39
  116. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  117. package/dist/unstable/ai/Chat.js +2 -1
  118. package/dist/unstable/ai/Chat.js.map +1 -1
  119. package/dist/unstable/ai/McpSchema.d.ts +51 -51
  120. package/dist/unstable/ai/Prompt.d.ts +20 -20
  121. package/dist/unstable/ai/Response.d.ts +25 -25
  122. package/dist/unstable/cli/CliError.d.ts +5 -5
  123. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  124. package/dist/unstable/cluster/ClusterWorkflowEngine.js +2 -1
  125. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  126. package/dist/unstable/cluster/Entity.d.ts +2 -1
  127. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  128. package/dist/unstable/cluster/Entity.js.map +1 -1
  129. package/dist/unstable/cluster/Envelope.d.ts +1 -1
  130. package/dist/unstable/cluster/K8sHttpClient.d.ts +1 -1
  131. package/dist/unstable/cluster/Message.d.ts +5 -5
  132. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  133. package/dist/unstable/cluster/MessageStorage.js +2 -1
  134. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  135. package/dist/unstable/cluster/Reply.d.ts +3 -3
  136. package/dist/unstable/cluster/Runner.d.ts +1 -1
  137. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  138. package/dist/unstable/cluster/Runners.js +4 -3
  139. package/dist/unstable/cluster/Runners.js.map +1 -1
  140. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  141. package/dist/unstable/cluster/Sharding.js +7 -5
  142. package/dist/unstable/cluster/Sharding.js.map +1 -1
  143. package/dist/unstable/cluster/internal/entityManager.js +4 -3
  144. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  145. package/dist/unstable/cluster/internal/entityReaper.js +2 -1
  146. package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
  147. package/dist/unstable/cluster/internal/resourceRef.js +2 -1
  148. package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
  149. package/dist/unstable/devtools/DevToolsSchema.d.ts +36 -36
  150. package/dist/unstable/encoding/Sse.d.ts +1 -1
  151. package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
  152. package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
  153. package/dist/unstable/eventlog/EventLog.js +2 -1
  154. package/dist/unstable/eventlog/EventLog.js.map +1 -1
  155. package/dist/unstable/eventlog/EventLogRemote.d.ts +5 -5
  156. package/dist/unstable/http/Cookies.d.ts +1 -1
  157. package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
  158. package/dist/unstable/http/HttpEffect.js +18 -26
  159. package/dist/unstable/http/HttpEffect.js.map +1 -1
  160. package/dist/unstable/http/Multipart.d.ts +2 -2
  161. package/dist/unstable/http/UrlParams.d.ts +1 -1
  162. package/dist/unstable/httpapi/HttpApiBuilder.js +2 -2
  163. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  164. package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
  165. package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
  166. package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
  167. package/dist/unstable/persistence/KeyValueStore.js +6 -6
  168. package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
  169. package/dist/unstable/persistence/PersistedCache.d.ts +6 -5
  170. package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
  171. package/dist/unstable/persistence/PersistedCache.js +2 -1
  172. package/dist/unstable/persistence/PersistedCache.js.map +1 -1
  173. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  174. package/dist/unstable/persistence/PersistedQueue.js +6 -5
  175. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  176. package/dist/unstable/process/ChildProcessSpawner.d.ts +6 -0
  177. package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
  178. package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
  179. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  180. package/dist/unstable/reactivity/Atom.js +12 -9
  181. package/dist/unstable/reactivity/Atom.js.map +1 -1
  182. package/dist/unstable/reactivity/Hydration.d.ts +39 -0
  183. package/dist/unstable/reactivity/Hydration.d.ts.map +1 -0
  184. package/dist/unstable/reactivity/Hydration.js +76 -0
  185. package/dist/unstable/reactivity/Hydration.js.map +1 -0
  186. package/dist/unstable/reactivity/index.d.ts +4 -0
  187. package/dist/unstable/reactivity/index.d.ts.map +1 -1
  188. package/dist/unstable/reactivity/index.js +4 -0
  189. package/dist/unstable/reactivity/index.js.map +1 -1
  190. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  191. package/dist/unstable/rpc/RpcClient.js +3 -2
  192. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  193. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  194. package/dist/unstable/rpc/RpcServer.js +5 -3
  195. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  196. package/dist/unstable/rpc/Utils.d.ts.map +1 -1
  197. package/dist/unstable/rpc/Utils.js +2 -1
  198. package/dist/unstable/rpc/Utils.js.map +1 -1
  199. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  200. package/dist/unstable/socket/Socket.js +3 -2
  201. package/dist/unstable/socket/Socket.js.map +1 -1
  202. package/dist/unstable/sql/Statement.js +0 -1
  203. package/dist/unstable/sql/Statement.js.map +1 -1
  204. package/dist/unstable/workers/Worker.d.ts.map +1 -1
  205. package/dist/unstable/workers/Worker.js +2 -1
  206. package/dist/unstable/workers/Worker.js.map +1 -1
  207. package/dist/unstable/workflow/DurableDeferred.js +2 -2
  208. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  209. package/dist/unstable/workflow/Workflow.d.ts +1 -1
  210. package/dist/unstable/workflow/WorkflowEngine.d.ts +2 -1
  211. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  212. package/dist/unstable/workflow/WorkflowEngine.js +2 -1
  213. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  214. package/package.json +1 -2
  215. package/src/Cause.ts +1 -1
  216. package/src/Channel.ts +6 -4
  217. package/src/Data.ts +10 -9
  218. package/src/Effect.ts +0 -246
  219. package/src/Encoding.ts +879 -0
  220. package/src/Equal.ts +2 -2
  221. package/src/FileSystem.ts +7 -8
  222. package/src/Filter.ts +48 -1
  223. package/src/Formatter.ts +1 -1
  224. package/src/Graph.ts +8 -5
  225. package/src/Latch.ts +112 -0
  226. package/src/Pipeable.ts +32 -1
  227. package/src/PlatformError.ts +5 -5
  228. package/src/Pool.ts +9 -7
  229. package/src/PubSub.ts +10 -9
  230. package/src/Request.ts +3 -2
  231. package/src/RequestResolver.ts +0 -20
  232. package/src/Schedule.ts +217 -115
  233. package/src/Schema.ts +567 -105
  234. package/src/SchemaGetter.ts +12 -14
  235. package/src/SchemaRepresentation.ts +5 -2
  236. package/src/SchemaTransformation.ts +104 -0
  237. package/src/Semaphore.ts +356 -0
  238. package/src/Stream.ts +9 -8
  239. package/src/Struct.ts +26 -0
  240. package/src/SubscriptionRef.ts +3 -2
  241. package/src/SynchronizedRef.ts +3 -2
  242. package/src/Types.ts +12 -2
  243. package/src/index.ts +17 -6
  244. package/src/internal/core.ts +10 -2
  245. package/src/internal/effect.ts +3 -2
  246. package/src/internal/rcRef.ts +2 -1
  247. package/src/testing/TestClock.ts +8 -6
  248. package/src/unstable/ai/AiError.ts +1 -1
  249. package/src/unstable/ai/Chat.ts +2 -1
  250. package/src/unstable/ai/Prompt.ts +20 -20
  251. package/src/unstable/ai/Response.ts +22 -22
  252. package/src/unstable/cluster/ClusterWorkflowEngine.ts +3 -2
  253. package/src/unstable/cluster/Entity.ts +2 -1
  254. package/src/unstable/cluster/Envelope.ts +1 -1
  255. package/src/unstable/cluster/MessageStorage.ts +2 -1
  256. package/src/unstable/cluster/Runners.ts +6 -5
  257. package/src/unstable/cluster/Sharding.ts +8 -6
  258. package/src/unstable/cluster/internal/entityManager.ts +6 -5
  259. package/src/unstable/cluster/internal/entityReaper.ts +2 -1
  260. package/src/unstable/cluster/internal/resourceRef.ts +2 -1
  261. package/src/unstable/eventlog/EventLog.ts +2 -1
  262. package/src/unstable/http/HttpEffect.ts +17 -25
  263. package/src/unstable/http/Multipart.ts +2 -2
  264. package/src/unstable/http/UrlParams.ts +1 -1
  265. package/src/unstable/httpapi/HttpApiBuilder.ts +2 -2
  266. package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
  267. package/src/unstable/persistence/KeyValueStore.ts +6 -6
  268. package/src/unstable/persistence/PersistedCache.ts +20 -9
  269. package/src/unstable/persistence/PersistedQueue.ts +7 -6
  270. package/src/unstable/process/ChildProcessSpawner.ts +6 -0
  271. package/src/unstable/reactivity/Atom.ts +7 -5
  272. package/src/unstable/reactivity/Hydration.ts +112 -0
  273. package/src/unstable/reactivity/index.ts +5 -0
  274. package/src/unstable/rpc/RpcClient.ts +4 -3
  275. package/src/unstable/rpc/RpcServer.ts +6 -4
  276. package/src/unstable/rpc/Utils.ts +2 -1
  277. package/src/unstable/socket/Socket.ts +3 -2
  278. package/src/unstable/sql/Statement.ts +0 -1
  279. package/src/unstable/workers/Worker.ts +2 -1
  280. package/src/unstable/workflow/DurableDeferred.ts +2 -2
  281. package/src/unstable/workflow/WorkflowEngine.ts +3 -2
  282. package/dist/PartitionedSemaphore.d.ts +0 -52
  283. package/dist/PartitionedSemaphore.d.ts.map +0 -1
  284. package/dist/PartitionedSemaphore.js.map +0 -1
  285. package/dist/encoding/Base64.d.ts +0 -67
  286. package/dist/encoding/Base64.d.ts.map +0 -1
  287. package/dist/encoding/Base64.js +0 -146
  288. package/dist/encoding/Base64.js.map +0 -1
  289. package/dist/encoding/Base64Url.d.ts +0 -60
  290. package/dist/encoding/Base64Url.d.ts.map +0 -1
  291. package/dist/encoding/Base64Url.js +0 -89
  292. package/dist/encoding/Base64Url.js.map +0 -1
  293. package/dist/encoding/EncodingError.d.ts +0 -31
  294. package/dist/encoding/EncodingError.d.ts.map +0 -1
  295. package/dist/encoding/EncodingError.js +0 -22
  296. package/dist/encoding/EncodingError.js.map +0 -1
  297. package/dist/encoding/Hex.d.ts +0 -61
  298. package/dist/encoding/Hex.d.ts.map +0 -1
  299. package/dist/encoding/Hex.js +0 -115
  300. package/dist/encoding/Hex.js.map +0 -1
  301. package/dist/encoding/index.d.ts +0 -26
  302. package/dist/encoding/index.d.ts.map +0 -1
  303. package/dist/encoding/index.js +0 -27
  304. package/dist/encoding/index.js.map +0 -1
  305. package/src/PartitionedSemaphore.ts +0 -182
  306. package/src/encoding/Base64.ts +0 -366
  307. package/src/encoding/Base64Url.ts +0 -104
  308. package/src/encoding/EncodingError.ts +0 -35
  309. package/src/encoding/Hex.ts +0 -390
  310. package/src/encoding/index.ts +0 -31
package/dist/Effect.d.ts CHANGED
@@ -11890,232 +11890,6 @@ export declare const uninterruptibleMask: <A, E, R>(f: (restore: <AX, EX, RX>(ef
11890
11890
  * @category Interruption
11891
11891
  */
11892
11892
  export declare const interruptibleMask: <A, E, R>(f: (restore: <AX, EX, RX>(effect: Effect<AX, EX, RX>) => Effect<AX, EX, RX>) => Effect<A, E, R>) => Effect<A, E, R>;
11893
- /**
11894
- * @category Semaphore
11895
- * @since 2.0.0
11896
- * @example
11897
- * ```ts
11898
- * import { Effect } from "effect"
11899
- *
11900
- * // Create and use a semaphore for controlling concurrent access
11901
- * const program = Effect.gen(function*() {
11902
- * const semaphore = yield* Effect.makeSemaphore(2)
11903
- *
11904
- * return yield* semaphore.withPermits(1)(
11905
- * Effect.succeed("Resource accessed")
11906
- * )
11907
- * })
11908
- * ```
11909
- */
11910
- export interface Semaphore {
11911
- /**
11912
- * Adjusts the number of permits available in the semaphore.
11913
- */
11914
- resize(permits: number): Effect<void>;
11915
- /**
11916
- * Runs an effect with the given number of permits and releases the permits
11917
- * when the effect completes.
11918
- *
11919
- * **Details**
11920
- *
11921
- * This function acquires the specified number of permits before executing
11922
- * the provided effect. Once the effect finishes, the permits are released.
11923
- * If insufficient permits are available, the function will wait until they
11924
- * are released by other tasks.
11925
- */
11926
- withPermits(permits: number): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>;
11927
- /**
11928
- * Runs an effect with the given number of permits and releases the permits
11929
- * when the effect completes.
11930
- *
11931
- * **Details**
11932
- *
11933
- * This function acquires the specified number of permits before executing
11934
- * the provided effect. Once the effect finishes, the permits are released.
11935
- * If insufficient permits are available, the function will wait until they
11936
- * are released by other tasks.
11937
- */
11938
- withPermit<A, E, R>(self: Effect<A, E, R>): Effect<A, E, R>;
11939
- /**
11940
- * Runs an effect only if the specified number of permits are immediately
11941
- * available.
11942
- *
11943
- * **Details**
11944
- *
11945
- * This function attempts to acquire the specified number of permits. If they
11946
- * are available, it runs the effect and releases the permits after the effect
11947
- * completes. If permits are not available, the effect does not execute, and
11948
- * the result is `Option.none`.
11949
- */
11950
- withPermitsIfAvailable(permits: number): <A, E, R>(self: Effect<A, E, R>) => Effect<Option<A>, E, R>;
11951
- /**
11952
- * Acquires the specified number of permits and returns the resulting
11953
- * available permits, suspending the task if they are not yet available.
11954
- * Concurrent pending `take` calls are processed in a first-in, first-out manner.
11955
- */
11956
- take(permits: number): Effect<number>;
11957
- /**
11958
- * Releases the specified number of permits and returns the resulting
11959
- * available permits.
11960
- */
11961
- release(permits: number): Effect<number>;
11962
- /**
11963
- * Releases all permits held by this semaphore and returns the resulting available permits.
11964
- */
11965
- releaseAll: Effect<number>;
11966
- }
11967
- /**
11968
- * Unsafely creates a new Semaphore.
11969
- *
11970
- * @example
11971
- * ```ts
11972
- * import { Effect } from "effect"
11973
- *
11974
- * const semaphore = Effect.makeSemaphoreUnsafe(3)
11975
- *
11976
- * const task = (id: number) =>
11977
- * semaphore.withPermits(1)(
11978
- * Effect.gen(function*() {
11979
- * yield* Effect.log(`Task ${id} started`)
11980
- * yield* Effect.sleep("1 second")
11981
- * yield* Effect.log(`Task ${id} completed`)
11982
- * })
11983
- * )
11984
- *
11985
- * // Only 3 tasks can run concurrently
11986
- * const program = Effect.all([
11987
- * task(1),
11988
- * task(2),
11989
- * task(3),
11990
- * task(4),
11991
- * task(5)
11992
- * ], { concurrency: "unbounded" })
11993
- * ```
11994
- *
11995
- * @since 2.0.0
11996
- * @category Semaphore
11997
- */
11998
- export declare const makeSemaphoreUnsafe: (permits: number) => Semaphore;
11999
- /**
12000
- * Creates a new Semaphore.
12001
- *
12002
- * @example
12003
- * ```ts
12004
- * import { Effect } from "effect"
12005
- *
12006
- * const program = Effect.gen(function*() {
12007
- * const semaphore = yield* Effect.makeSemaphore(2)
12008
- *
12009
- * const task = (id: number) =>
12010
- * semaphore.withPermits(1)(
12011
- * Effect.gen(function*() {
12012
- * yield* Effect.log(`Task ${id} acquired permit`)
12013
- * yield* Effect.sleep("1 second")
12014
- * yield* Effect.log(`Task ${id} releasing permit`)
12015
- * })
12016
- * )
12017
- *
12018
- * // Run 4 tasks, but only 2 can run concurrently
12019
- * yield* Effect.all([task(1), task(2), task(3), task(4)])
12020
- * })
12021
- * ```
12022
- *
12023
- * @since 2.0.0
12024
- * @category Semaphore
12025
- */
12026
- export declare const makeSemaphore: (permits: number) => Effect<Semaphore>;
12027
- /**
12028
- * @category Latch
12029
- * @since 3.8.0
12030
- * @example
12031
- * ```ts
12032
- * import { Effect } from "effect"
12033
- *
12034
- * // Create and use a latch for coordination between fibers
12035
- * const program = Effect.gen(function*() {
12036
- * const latch = yield* Effect.makeLatch()
12037
- *
12038
- * // Wait for the latch to be opened
12039
- * yield* latch.await
12040
- *
12041
- * return "Latch was opened!"
12042
- * })
12043
- * ```
12044
- */
12045
- export interface Latch {
12046
- /** open the latch, releasing all fibers waiting on it */
12047
- readonly open: Effect<boolean>;
12048
- /** open the latch, releasing all fibers waiting on it */
12049
- readonly openUnsafe: () => boolean;
12050
- /** release all fibers waiting on the latch, without opening it */
12051
- readonly release: Effect<boolean>;
12052
- /** wait for the latch to be opened */
12053
- readonly await: Effect<void>;
12054
- /** close the latch */
12055
- readonly close: Effect<boolean>;
12056
- /** close the latch */
12057
- readonly closeUnsafe: () => boolean;
12058
- /** only run the given effect when the latch is open */
12059
- readonly whenOpen: <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>;
12060
- }
12061
- /**
12062
- * Creates a new Latch.
12063
- *
12064
- * @example
12065
- * ```ts
12066
- * import { Effect } from "effect"
12067
- *
12068
- * const latch = Effect.makeLatchUnsafe(false)
12069
- *
12070
- * const waiter = Effect.gen(function*() {
12071
- * yield* Effect.log("Waiting for latch to open...")
12072
- * yield* latch.await
12073
- * yield* Effect.log("Latch opened! Continuing...")
12074
- * })
12075
- *
12076
- * const opener = Effect.gen(function*() {
12077
- * yield* Effect.sleep("2 seconds")
12078
- * yield* Effect.log("Opening latch...")
12079
- * yield* latch.open
12080
- * })
12081
- *
12082
- * const program = Effect.all([waiter, opener])
12083
- * ```
12084
- *
12085
- * @category Latch
12086
- * @since 3.8.0
12087
- */
12088
- export declare const makeLatchUnsafe: (open?: boolean | undefined) => Latch;
12089
- /**
12090
- * Creates a new Latch.
12091
- *
12092
- * @example
12093
- * ```ts
12094
- * import { Effect } from "effect"
12095
- *
12096
- * const program = Effect.gen(function*() {
12097
- * const latch = yield* Effect.makeLatch(false)
12098
- *
12099
- * const waiter = Effect.gen(function*() {
12100
- * yield* Effect.log("Waiting for latch to open...")
12101
- * yield* latch.await
12102
- * yield* Effect.log("Latch opened! Continuing...")
12103
- * })
12104
- *
12105
- * const opener = Effect.gen(function*() {
12106
- * yield* Effect.sleep("2 seconds")
12107
- * yield* Effect.log("Opening latch...")
12108
- * yield* latch.open
12109
- * })
12110
- *
12111
- * yield* Effect.all([waiter, opener])
12112
- * })
12113
- * ```
12114
- *
12115
- * @category Latch
12116
- * @since 3.8.0
12117
- */
12118
- export declare const makeLatch: (open?: boolean | undefined) => Effect<Latch>;
12119
11893
  /**
12120
11894
  * @since 2.0.0
12121
11895
  * @category Repetition / Recursion