effect 4.0.0-beta.31 → 4.0.0-beta.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Array.d.ts +87 -86
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +47 -40
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +46 -45
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +35 -38
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts +39 -32
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +32 -29
- package/dist/BigInt.js.map +1 -1
- package/dist/Chunk.d.ts +58 -57
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +20 -21
- package/dist/Chunk.js.map +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +4 -1
- package/dist/Config.js.map +1 -1
- package/dist/Cron.d.ts +3 -6
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +8 -15
- package/dist/Cron.js.map +1 -1
- package/dist/DateTime.d.ts +16 -15
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +8 -8
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +7 -5
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +7 -5
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +26 -24
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +23 -22
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +3 -4
- package/dist/Effect.js.map +1 -1
- package/dist/Fiber.d.ts +2 -1
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +9 -8
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +8 -7
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +20 -19
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +6 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +17 -16
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +10 -7
- package/dist/FileSystem.js.map +1 -1
- package/dist/Graph.d.ts +64 -64
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +53 -53
- package/dist/Graph.js.map +1 -1
- package/dist/HashMap.d.ts +11 -5
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +3 -1
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +11 -11
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +12 -12
- package/dist/Iterable.js.map +1 -1
- package/dist/Latch.d.ts +69 -3
- package/dist/Latch.d.ts.map +1 -1
- package/dist/Latch.js +58 -0
- package/dist/Latch.js.map +1 -1
- package/dist/Layer.d.ts +84 -0
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +27 -0
- package/dist/Layer.js.map +1 -1
- package/dist/Number.d.ts +74 -18
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +34 -15
- package/dist/Number.js.map +1 -1
- package/dist/Option.d.ts +2 -0
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts +183 -0
- package/dist/PartitionedSemaphore.d.ts.map +1 -0
- package/dist/PartitionedSemaphore.js +231 -0
- package/dist/PartitionedSemaphore.js.map +1 -0
- package/dist/PubSub.d.ts +5 -4
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +6 -5
- package/dist/PubSub.js.map +1 -1
- package/dist/Queue.d.ts +3 -3
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +2 -2
- package/dist/Queue.js.map +1 -1
- package/dist/Record.d.ts +40 -40
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +16 -15
- package/dist/Record.js.map +1 -1
- package/dist/Scheduler.d.ts +25 -123
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +20 -123
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +30 -0
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +28 -1
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaGetter.js +6 -4
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +32 -27
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Semaphore.d.ts +149 -53
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +137 -117
- package/dist/Semaphore.js.map +1 -1
- package/dist/ServiceMap.d.ts +26 -0
- package/dist/ServiceMap.d.ts.map +1 -1
- package/dist/ServiceMap.js +36 -21
- package/dist/ServiceMap.js.map +1 -1
- package/dist/Stream.js +1 -1
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +114 -47
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +29 -47
- package/dist/String.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +1 -2
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +81 -115
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/Terminal.d.ts +2 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +5 -4
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +2 -1
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +26 -14
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +8 -4
- package/dist/Trie.js.map +1 -1
- package/dist/TxHashMap.d.ts +77 -59
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +25 -19
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxSemaphore.d.ts +162 -2
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +16 -2
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/index.d.ts +88 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +88 -32
- package/dist/index.js.map +1 -1
- package/dist/internal/dateTime.js +9 -9
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +20 -89
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +2 -1
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/option.js +6 -0
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/trie.js +3 -3
- package/dist/internal/trie.js.map +1 -1
- package/dist/unstable/ai/AiError.js +1 -1
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +2 -2
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +14 -0
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +13 -0
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +2 -4
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +1 -3
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +3 -2
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +4 -3
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +3 -2
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +3 -3
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +2 -2
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/HelpDoc.d.ts +14 -12
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +4 -4
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +7 -7
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +1 -1
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +71 -67
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js +9 -2
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +8 -3
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +25 -23
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +3 -2
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +7 -7
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +4 -3
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +3 -2
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +12 -12
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +2 -1
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +4 -3
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +9 -8
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +2 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +7 -6
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +19 -13
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +5 -4
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +4 -4
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +9 -10
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +2 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +1 -4
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +5 -4
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +3 -4
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts.map +1 -1
- package/dist/unstable/http/Etag.js +5 -1
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +3 -2
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +2 -1
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +2 -1
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +4 -3
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +8 -6
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +2 -1
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +2 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +16 -15
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +3 -2
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +2 -1
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +7 -7
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +2 -2
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +2 -1
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +2 -1
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +3 -2
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +14 -10
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +4 -3
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
- package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js +27 -15
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +5 -4
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +5 -6
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +4 -2
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +15 -0
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +81 -3
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +2 -2
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +7 -3
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +1 -5
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +4 -2
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -3
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +4 -4
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +3 -2
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +4 -1
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +3 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +2 -1
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +1 -1
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +6 -6
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +2 -1
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +5 -4
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +19 -14
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +112 -105
- package/src/BigDecimal.ts +63 -66
- package/src/BigInt.ts +49 -41
- package/src/Chunk.ts +68 -63
- package/src/Config.ts +4 -1
- package/src/Cron.ts +10 -15
- package/src/DateTime.ts +16 -15
- package/src/Deferred.ts +8 -6
- package/src/Duration.ts +34 -33
- package/src/Effect.ts +3 -4
- package/src/Fiber.ts +2 -1
- package/src/FiberHandle.ts +10 -9
- package/src/FiberMap.ts +22 -22
- package/src/FileSystem.ts +25 -22
- package/src/Graph.ts +105 -105
- package/src/HashMap.ts +11 -5
- package/src/Iterable.ts +13 -13
- package/src/Latch.ts +85 -3
- package/src/Layer.ts +121 -0
- package/src/Number.ts +85 -26
- package/src/Option.ts +2 -0
- package/src/PartitionedSemaphore.ts +414 -0
- package/src/PubSub.ts +7 -6
- package/src/Queue.ts +5 -5
- package/src/Record.ts +52 -47
- package/src/Scheduler.ts +37 -126
- package/src/Schema.ts +49 -1
- package/src/SchemaGetter.ts +4 -4
- package/src/SchemaTransformation.ts +27 -27
- package/src/Semaphore.ts +271 -183
- package/src/ServiceMap.ts +83 -31
- package/src/Stream.ts +1 -1
- package/src/String.ts +122 -69
- package/src/SubscriptionRef.ts +96 -117
- package/src/Terminal.ts +2 -1
- package/src/Tracer.ts +6 -5
- package/src/Trie.ts +26 -14
- package/src/TxHashMap.ts +78 -60
- package/src/TxSemaphore.ts +186 -11
- package/src/index.ts +89 -33
- package/src/internal/dateTime.ts +14 -14
- package/src/internal/effect.ts +29 -121
- package/src/internal/hashMap.ts +4 -3
- package/src/internal/option.ts +7 -0
- package/src/internal/trie.ts +6 -6
- package/src/unstable/ai/AiError.ts +1 -1
- package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
- package/src/unstable/ai/Chat.ts +6 -2
- package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
- package/src/unstable/ai/Tool.ts +20 -0
- package/src/unstable/cli/Argument.ts +2 -4
- package/src/unstable/cli/CliOutput.ts +7 -5
- package/src/unstable/cli/Command.ts +5 -5
- package/src/unstable/cli/Flag.ts +2 -2
- package/src/unstable/cli/HelpDoc.ts +14 -12
- package/src/unstable/cli/Param.ts +15 -11
- package/src/unstable/cli/Primitive.ts +1 -1
- package/src/unstable/cli/Prompt.ts +81 -83
- package/src/unstable/cli/internal/completions/CommandDescriptor.ts +3 -2
- package/src/unstable/cli/internal/parser.ts +7 -4
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +35 -30
- package/src/unstable/cluster/Entity.ts +13 -12
- package/src/unstable/cluster/Message.ts +6 -5
- package/src/unstable/cluster/MessageStorage.ts +26 -25
- package/src/unstable/cluster/Reply.ts +7 -4
- package/src/unstable/cluster/RunnerServer.ts +10 -13
- package/src/unstable/cluster/Runners.ts +8 -7
- package/src/unstable/cluster/Sharding.ts +24 -17
- package/src/unstable/cluster/ShardingConfig.ts +6 -6
- package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
- package/src/unstable/cluster/internal/entityManager.ts +27 -21
- package/src/unstable/devtools/DevToolsSchema.ts +3 -2
- package/src/unstable/http/Cookies.ts +7 -8
- package/src/unstable/http/Etag.ts +5 -3
- package/src/unstable/http/Headers.ts +6 -5
- package/src/unstable/http/HttpClient.ts +2 -1
- package/src/unstable/http/HttpClientRequest.ts +11 -9
- package/src/unstable/http/HttpClientResponse.ts +3 -2
- package/src/unstable/http/HttpIncomingMessage.ts +2 -1
- package/src/unstable/http/HttpMiddleware.ts +16 -15
- package/src/unstable/http/HttpPlatform.ts +3 -2
- package/src/unstable/http/HttpRouter.ts +9 -9
- package/src/unstable/http/HttpServer.ts +3 -9
- package/src/unstable/http/HttpServerError.ts +3 -2
- package/src/unstable/http/HttpServerRequest.ts +25 -21
- package/src/unstable/http/HttpServerResponse.ts +5 -4
- package/src/unstable/http/HttpTraceContext.ts +31 -17
- package/src/unstable/http/UrlParams.ts +11 -14
- package/src/unstable/httpapi/HttpApiBuilder.ts +9 -3
- package/src/unstable/httpapi/HttpApiError.ts +67 -12
- package/src/unstable/observability/OtlpExporter.ts +5 -2
- package/src/unstable/observability/OtlpTracer.ts +8 -4
- package/src/unstable/reactivity/Atom.ts +1 -4
- package/src/unstable/reactivity/AtomRegistry.ts +5 -3
- package/src/unstable/rpc/Rpc.ts +4 -3
- package/src/unstable/rpc/RpcClient.ts +10 -9
- package/src/unstable/rpc/RpcSchema.ts +6 -5
- package/src/unstable/rpc/RpcSerialization.ts +4 -1
- package/src/unstable/rpc/RpcServer.ts +3 -3
- package/src/unstable/socket/Socket.ts +2 -1
- package/src/unstable/sql/SqlClient.ts +5 -3
- package/src/unstable/workflow/DurableDeferred.ts +6 -6
- package/src/unstable/workflow/Workflow.ts +1 -1
- package/src/unstable/workflow/WorkflowEngine.ts +29 -20
- package/dist/NullOr.d.ts +0 -149
- package/dist/NullOr.d.ts.map +0 -1
- package/dist/NullOr.js +0 -152
- package/dist/NullOr.js.map +0 -1
- package/src/NullOr.ts +0 -204
package/src/BigDecimal.ts
CHANGED
|
@@ -19,6 +19,7 @@ import * as Equ from "./Equivalence.ts"
|
|
|
19
19
|
import { dual } from "./Function.ts"
|
|
20
20
|
import * as Hash from "./Hash.ts"
|
|
21
21
|
import { type Inspectable, NodeInspectSymbol } from "./Inspectable.ts"
|
|
22
|
+
import * as Option from "./Option.ts"
|
|
22
23
|
import * as order from "./Order.ts"
|
|
23
24
|
import type { Ordering } from "./Ordering.ts"
|
|
24
25
|
import { type Pipeable, pipeArguments } from "./Pipeable.ts"
|
|
@@ -565,11 +566,11 @@ export const roundTerminal = (n: bigint): bigint => {
|
|
|
565
566
|
* If the dividend is not a multiple of the divisor the result will be a `BigDecimal` value
|
|
566
567
|
* which represents the integer division rounded down to the nearest integer.
|
|
567
568
|
*
|
|
568
|
-
* If the divisor is `0`, the result will be `
|
|
569
|
+
* If the divisor is `0`, the result will be `Option.none()`.
|
|
569
570
|
*
|
|
570
571
|
* @example
|
|
571
572
|
* ```ts
|
|
572
|
-
* import { BigDecimal } from "effect"
|
|
573
|
+
* import { BigDecimal, Option } from "effect"
|
|
573
574
|
* import * as assert from "node:assert"
|
|
574
575
|
*
|
|
575
576
|
* assert.deepStrictEqual(
|
|
@@ -577,21 +578,21 @@ export const roundTerminal = (n: bigint): bigint => {
|
|
|
577
578
|
* BigDecimal.fromStringUnsafe("6"),
|
|
578
579
|
* BigDecimal.fromStringUnsafe("3")
|
|
579
580
|
* ),
|
|
580
|
-
* BigDecimal.fromStringUnsafe("2")
|
|
581
|
+
* Option.some(BigDecimal.fromStringUnsafe("2"))
|
|
581
582
|
* )
|
|
582
583
|
* assert.deepStrictEqual(
|
|
583
584
|
* BigDecimal.divide(
|
|
584
585
|
* BigDecimal.fromStringUnsafe("6"),
|
|
585
586
|
* BigDecimal.fromStringUnsafe("4")
|
|
586
587
|
* ),
|
|
587
|
-
* BigDecimal.fromStringUnsafe("1.5")
|
|
588
|
+
* Option.some(BigDecimal.fromStringUnsafe("1.5"))
|
|
588
589
|
* )
|
|
589
590
|
* assert.deepStrictEqual(
|
|
590
591
|
* BigDecimal.divide(
|
|
591
592
|
* BigDecimal.fromStringUnsafe("6"),
|
|
592
593
|
* BigDecimal.fromStringUnsafe("0")
|
|
593
594
|
* ),
|
|
594
|
-
*
|
|
595
|
+
* Option.none()
|
|
595
596
|
* )
|
|
596
597
|
* ```
|
|
597
598
|
*
|
|
@@ -605,11 +606,11 @@ export const divide: {
|
|
|
605
606
|
* If the dividend is not a multiple of the divisor the result will be a `BigDecimal` value
|
|
606
607
|
* which represents the integer division rounded down to the nearest integer.
|
|
607
608
|
*
|
|
608
|
-
* If the divisor is `0`, the result will be `
|
|
609
|
+
* If the divisor is `0`, the result will be `Option.none()`.
|
|
609
610
|
*
|
|
610
611
|
* @example
|
|
611
612
|
* ```ts
|
|
612
|
-
* import { BigDecimal } from "effect"
|
|
613
|
+
* import { BigDecimal, Option } from "effect"
|
|
613
614
|
* import * as assert from "node:assert"
|
|
614
615
|
*
|
|
615
616
|
* assert.deepStrictEqual(
|
|
@@ -617,39 +618,39 @@ export const divide: {
|
|
|
617
618
|
* BigDecimal.fromStringUnsafe("6"),
|
|
618
619
|
* BigDecimal.fromStringUnsafe("3")
|
|
619
620
|
* ),
|
|
620
|
-
* BigDecimal.fromStringUnsafe("2")
|
|
621
|
+
* Option.some(BigDecimal.fromStringUnsafe("2"))
|
|
621
622
|
* )
|
|
622
623
|
* assert.deepStrictEqual(
|
|
623
624
|
* BigDecimal.divide(
|
|
624
625
|
* BigDecimal.fromStringUnsafe("6"),
|
|
625
626
|
* BigDecimal.fromStringUnsafe("4")
|
|
626
627
|
* ),
|
|
627
|
-
* BigDecimal.fromStringUnsafe("1.5")
|
|
628
|
+
* Option.some(BigDecimal.fromStringUnsafe("1.5"))
|
|
628
629
|
* )
|
|
629
630
|
* assert.deepStrictEqual(
|
|
630
631
|
* BigDecimal.divide(
|
|
631
632
|
* BigDecimal.fromStringUnsafe("6"),
|
|
632
633
|
* BigDecimal.fromStringUnsafe("0")
|
|
633
634
|
* ),
|
|
634
|
-
*
|
|
635
|
+
* Option.none()
|
|
635
636
|
* )
|
|
636
637
|
* ```
|
|
637
638
|
*
|
|
638
639
|
* @since 2.0.0
|
|
639
640
|
* @category math
|
|
640
641
|
*/
|
|
641
|
-
(that: BigDecimal): (self: BigDecimal) => BigDecimal
|
|
642
|
+
(that: BigDecimal): (self: BigDecimal) => Option.Option<BigDecimal>
|
|
642
643
|
/**
|
|
643
644
|
* Provides a division operation on `BigDecimal`s.
|
|
644
645
|
*
|
|
645
646
|
* If the dividend is not a multiple of the divisor the result will be a `BigDecimal` value
|
|
646
647
|
* which represents the integer division rounded down to the nearest integer.
|
|
647
648
|
*
|
|
648
|
-
* If the divisor is `0`, the result will be `
|
|
649
|
+
* If the divisor is `0`, the result will be `Option.none()`.
|
|
649
650
|
*
|
|
650
651
|
* @example
|
|
651
652
|
* ```ts
|
|
652
|
-
* import { BigDecimal } from "effect"
|
|
653
|
+
* import { BigDecimal, Option } from "effect"
|
|
653
654
|
* import * as assert from "node:assert"
|
|
654
655
|
*
|
|
655
656
|
* assert.deepStrictEqual(
|
|
@@ -657,43 +658,43 @@ export const divide: {
|
|
|
657
658
|
* BigDecimal.fromStringUnsafe("6"),
|
|
658
659
|
* BigDecimal.fromStringUnsafe("3")
|
|
659
660
|
* ),
|
|
660
|
-
* BigDecimal.fromStringUnsafe("2")
|
|
661
|
+
* Option.some(BigDecimal.fromStringUnsafe("2"))
|
|
661
662
|
* )
|
|
662
663
|
* assert.deepStrictEqual(
|
|
663
664
|
* BigDecimal.divide(
|
|
664
665
|
* BigDecimal.fromStringUnsafe("6"),
|
|
665
666
|
* BigDecimal.fromStringUnsafe("4")
|
|
666
667
|
* ),
|
|
667
|
-
* BigDecimal.fromStringUnsafe("1.5")
|
|
668
|
+
* Option.some(BigDecimal.fromStringUnsafe("1.5"))
|
|
668
669
|
* )
|
|
669
670
|
* assert.deepStrictEqual(
|
|
670
671
|
* BigDecimal.divide(
|
|
671
672
|
* BigDecimal.fromStringUnsafe("6"),
|
|
672
673
|
* BigDecimal.fromStringUnsafe("0")
|
|
673
674
|
* ),
|
|
674
|
-
*
|
|
675
|
+
* Option.none()
|
|
675
676
|
* )
|
|
676
677
|
* ```
|
|
677
678
|
*
|
|
678
679
|
* @since 2.0.0
|
|
679
680
|
* @category math
|
|
680
681
|
*/
|
|
681
|
-
(self: BigDecimal, that: BigDecimal): BigDecimal
|
|
682
|
-
} = dual(2, (self: BigDecimal, that: BigDecimal): BigDecimal
|
|
682
|
+
(self: BigDecimal, that: BigDecimal): Option.Option<BigDecimal>
|
|
683
|
+
} = dual(2, (self: BigDecimal, that: BigDecimal): Option.Option<BigDecimal> => {
|
|
683
684
|
if (that.value === bigint0) {
|
|
684
|
-
return
|
|
685
|
+
return Option.none()
|
|
685
686
|
}
|
|
686
687
|
|
|
687
688
|
if (self.value === bigint0) {
|
|
688
|
-
return zero
|
|
689
|
+
return Option.some(zero)
|
|
689
690
|
}
|
|
690
691
|
|
|
691
692
|
const scale = self.scale - that.scale
|
|
692
693
|
if (self.value === that.value) {
|
|
693
|
-
return make(bigint1, scale)
|
|
694
|
+
return Option.some(make(bigint1, scale))
|
|
694
695
|
}
|
|
695
696
|
|
|
696
|
-
return divideWithPrecision(self.value, that.value, scale, DEFAULT_PRECISION)
|
|
697
|
+
return Option.some(divideWithPrecision(self.value, that.value, scale, DEFAULT_PRECISION))
|
|
697
698
|
})
|
|
698
699
|
|
|
699
700
|
/**
|
|
@@ -1514,11 +1515,11 @@ export const negate = (n: BigDecimal): BigDecimal => make(-n.value, n.scale)
|
|
|
1514
1515
|
/**
|
|
1515
1516
|
* Returns the remainder left over when one operand is divided by a second operand.
|
|
1516
1517
|
*
|
|
1517
|
-
* If the divisor is `0`, the result will be `
|
|
1518
|
+
* If the divisor is `0`, the result will be `Option.none()`.
|
|
1518
1519
|
*
|
|
1519
1520
|
* @example
|
|
1520
1521
|
* ```ts
|
|
1521
|
-
* import { BigDecimal } from "effect"
|
|
1522
|
+
* import { BigDecimal, Option } from "effect"
|
|
1522
1523
|
* import * as assert from "node:assert"
|
|
1523
1524
|
*
|
|
1524
1525
|
* assert.deepStrictEqual(
|
|
@@ -1526,21 +1527,21 @@ export const negate = (n: BigDecimal): BigDecimal => make(-n.value, n.scale)
|
|
|
1526
1527
|
* BigDecimal.fromStringUnsafe("2"),
|
|
1527
1528
|
* BigDecimal.fromStringUnsafe("2")
|
|
1528
1529
|
* ),
|
|
1529
|
-
* BigDecimal.fromStringUnsafe("0")
|
|
1530
|
+
* Option.some(BigDecimal.fromStringUnsafe("0"))
|
|
1530
1531
|
* )
|
|
1531
1532
|
* assert.deepStrictEqual(
|
|
1532
1533
|
* BigDecimal.remainder(
|
|
1533
1534
|
* BigDecimal.fromStringUnsafe("3"),
|
|
1534
1535
|
* BigDecimal.fromStringUnsafe("2")
|
|
1535
1536
|
* ),
|
|
1536
|
-
* BigDecimal.fromStringUnsafe("1")
|
|
1537
|
+
* Option.some(BigDecimal.fromStringUnsafe("1"))
|
|
1537
1538
|
* )
|
|
1538
1539
|
* assert.deepStrictEqual(
|
|
1539
1540
|
* BigDecimal.remainder(
|
|
1540
1541
|
* BigDecimal.fromStringUnsafe("-4"),
|
|
1541
1542
|
* BigDecimal.fromStringUnsafe("2")
|
|
1542
1543
|
* ),
|
|
1543
|
-
* BigDecimal.fromStringUnsafe("0")
|
|
1544
|
+
* Option.some(BigDecimal.fromStringUnsafe("0"))
|
|
1544
1545
|
* )
|
|
1545
1546
|
* ```
|
|
1546
1547
|
*
|
|
@@ -1551,11 +1552,11 @@ export const remainder: {
|
|
|
1551
1552
|
/**
|
|
1552
1553
|
* Returns the remainder left over when one operand is divided by a second operand.
|
|
1553
1554
|
*
|
|
1554
|
-
* If the divisor is `0`, the result will be `
|
|
1555
|
+
* If the divisor is `0`, the result will be `Option.none()`.
|
|
1555
1556
|
*
|
|
1556
1557
|
* @example
|
|
1557
1558
|
* ```ts
|
|
1558
|
-
* import { BigDecimal } from "effect"
|
|
1559
|
+
* import { BigDecimal, Option } from "effect"
|
|
1559
1560
|
* import * as assert from "node:assert"
|
|
1560
1561
|
*
|
|
1561
1562
|
* assert.deepStrictEqual(
|
|
@@ -1563,36 +1564,36 @@ export const remainder: {
|
|
|
1563
1564
|
* BigDecimal.fromStringUnsafe("2"),
|
|
1564
1565
|
* BigDecimal.fromStringUnsafe("2")
|
|
1565
1566
|
* ),
|
|
1566
|
-
* BigDecimal.fromStringUnsafe("0")
|
|
1567
|
+
* Option.some(BigDecimal.fromStringUnsafe("0"))
|
|
1567
1568
|
* )
|
|
1568
1569
|
* assert.deepStrictEqual(
|
|
1569
1570
|
* BigDecimal.remainder(
|
|
1570
1571
|
* BigDecimal.fromStringUnsafe("3"),
|
|
1571
1572
|
* BigDecimal.fromStringUnsafe("2")
|
|
1572
1573
|
* ),
|
|
1573
|
-
* BigDecimal.fromStringUnsafe("1")
|
|
1574
|
+
* Option.some(BigDecimal.fromStringUnsafe("1"))
|
|
1574
1575
|
* )
|
|
1575
1576
|
* assert.deepStrictEqual(
|
|
1576
1577
|
* BigDecimal.remainder(
|
|
1577
1578
|
* BigDecimal.fromStringUnsafe("-4"),
|
|
1578
1579
|
* BigDecimal.fromStringUnsafe("2")
|
|
1579
1580
|
* ),
|
|
1580
|
-
* BigDecimal.fromStringUnsafe("0")
|
|
1581
|
+
* Option.some(BigDecimal.fromStringUnsafe("0"))
|
|
1581
1582
|
* )
|
|
1582
1583
|
* ```
|
|
1583
1584
|
*
|
|
1584
1585
|
* @since 2.0.0
|
|
1585
1586
|
* @category math
|
|
1586
1587
|
*/
|
|
1587
|
-
(divisor: BigDecimal): (self: BigDecimal) => BigDecimal
|
|
1588
|
+
(divisor: BigDecimal): (self: BigDecimal) => Option.Option<BigDecimal>
|
|
1588
1589
|
/**
|
|
1589
1590
|
* Returns the remainder left over when one operand is divided by a second operand.
|
|
1590
1591
|
*
|
|
1591
|
-
* If the divisor is `0`, the result will be `
|
|
1592
|
+
* If the divisor is `0`, the result will be `Option.none()`.
|
|
1592
1593
|
*
|
|
1593
1594
|
* @example
|
|
1594
1595
|
* ```ts
|
|
1595
|
-
* import { BigDecimal } from "effect"
|
|
1596
|
+
* import { BigDecimal, Option } from "effect"
|
|
1596
1597
|
* import * as assert from "node:assert"
|
|
1597
1598
|
*
|
|
1598
1599
|
* assert.deepStrictEqual(
|
|
@@ -1600,35 +1601,35 @@ export const remainder: {
|
|
|
1600
1601
|
* BigDecimal.fromStringUnsafe("2"),
|
|
1601
1602
|
* BigDecimal.fromStringUnsafe("2")
|
|
1602
1603
|
* ),
|
|
1603
|
-
* BigDecimal.fromStringUnsafe("0")
|
|
1604
|
+
* Option.some(BigDecimal.fromStringUnsafe("0"))
|
|
1604
1605
|
* )
|
|
1605
1606
|
* assert.deepStrictEqual(
|
|
1606
1607
|
* BigDecimal.remainder(
|
|
1607
1608
|
* BigDecimal.fromStringUnsafe("3"),
|
|
1608
1609
|
* BigDecimal.fromStringUnsafe("2")
|
|
1609
1610
|
* ),
|
|
1610
|
-
* BigDecimal.fromStringUnsafe("1")
|
|
1611
|
+
* Option.some(BigDecimal.fromStringUnsafe("1"))
|
|
1611
1612
|
* )
|
|
1612
1613
|
* assert.deepStrictEqual(
|
|
1613
1614
|
* BigDecimal.remainder(
|
|
1614
1615
|
* BigDecimal.fromStringUnsafe("-4"),
|
|
1615
1616
|
* BigDecimal.fromStringUnsafe("2")
|
|
1616
1617
|
* ),
|
|
1617
|
-
* BigDecimal.fromStringUnsafe("0")
|
|
1618
|
+
* Option.some(BigDecimal.fromStringUnsafe("0"))
|
|
1618
1619
|
* )
|
|
1619
1620
|
* ```
|
|
1620
1621
|
*
|
|
1621
1622
|
* @since 2.0.0
|
|
1622
1623
|
* @category math
|
|
1623
1624
|
*/
|
|
1624
|
-
(self: BigDecimal, divisor: BigDecimal): BigDecimal
|
|
1625
|
-
} = dual(2, (self: BigDecimal, divisor: BigDecimal): BigDecimal
|
|
1625
|
+
(self: BigDecimal, divisor: BigDecimal): Option.Option<BigDecimal>
|
|
1626
|
+
} = dual(2, (self: BigDecimal, divisor: BigDecimal): Option.Option<BigDecimal> => {
|
|
1626
1627
|
if (divisor.value === bigint0) {
|
|
1627
|
-
return
|
|
1628
|
+
return Option.none()
|
|
1628
1629
|
}
|
|
1629
1630
|
|
|
1630
1631
|
const max = Math.max(self.scale, divisor.scale)
|
|
1631
|
-
return make(scale(self, max).value % scale(divisor, max).value, max)
|
|
1632
|
+
return Option.some(make(scale(self, max).value % scale(divisor, max).value, max))
|
|
1632
1633
|
})
|
|
1633
1634
|
|
|
1634
1635
|
/**
|
|
@@ -1853,9 +1854,7 @@ export const fromBigInt = (n: bigint): BigDecimal => make(n, 0)
|
|
|
1853
1854
|
* @category constructors
|
|
1854
1855
|
*/
|
|
1855
1856
|
export const fromNumberUnsafe = (n: number): BigDecimal => {
|
|
1856
|
-
|
|
1857
|
-
if (out) return out
|
|
1858
|
-
throw new RangeError(`Number must be finite, got ${n}`)
|
|
1857
|
+
return Option.getOrThrowWith(fromNumber(n), () => new RangeError(`Number must be finite, got ${n}`))
|
|
1859
1858
|
}
|
|
1860
1859
|
|
|
1861
1860
|
/**
|
|
@@ -1864,27 +1863,27 @@ export const fromNumberUnsafe = (n: number): BigDecimal => {
|
|
|
1864
1863
|
* It is not recommended to convert a floating point number to a decimal directly,
|
|
1865
1864
|
* as the floating point representation may be unexpected.
|
|
1866
1865
|
*
|
|
1867
|
-
* Returns `
|
|
1866
|
+
* Returns `Option.none()` for `NaN`, `+Infinity` or `-Infinity`.
|
|
1868
1867
|
*
|
|
1869
1868
|
* @example
|
|
1870
1869
|
* ```ts
|
|
1871
|
-
* import { BigDecimal } from "effect"
|
|
1870
|
+
* import { BigDecimal, Option } from "effect"
|
|
1872
1871
|
* import * as assert from "node:assert"
|
|
1873
1872
|
*
|
|
1874
|
-
* assert.deepStrictEqual(BigDecimal.fromNumber(123), BigDecimal.make(123n, 0))
|
|
1873
|
+
* assert.deepStrictEqual(BigDecimal.fromNumber(123), Option.some(BigDecimal.make(123n, 0)))
|
|
1875
1874
|
* assert.deepStrictEqual(
|
|
1876
1875
|
* BigDecimal.fromNumber(123.456),
|
|
1877
|
-
* BigDecimal.make(123456n, 3)
|
|
1876
|
+
* Option.some(BigDecimal.make(123456n, 3))
|
|
1878
1877
|
* )
|
|
1879
|
-
* assert.deepStrictEqual(BigDecimal.fromNumber(Infinity),
|
|
1878
|
+
* assert.deepStrictEqual(BigDecimal.fromNumber(Infinity), Option.none())
|
|
1880
1879
|
* ```
|
|
1881
1880
|
*
|
|
1882
1881
|
* @since 4.0.0
|
|
1883
1882
|
* @category constructors
|
|
1884
1883
|
*/
|
|
1885
|
-
export const fromNumber = (n: number): BigDecimal
|
|
1884
|
+
export const fromNumber = (n: number): Option.Option<BigDecimal> => {
|
|
1886
1885
|
if (!Number.isFinite(n)) {
|
|
1887
|
-
return
|
|
1886
|
+
return Option.none()
|
|
1888
1887
|
}
|
|
1889
1888
|
|
|
1890
1889
|
const string = `${n}`
|
|
@@ -1893,7 +1892,7 @@ export const fromNumber = (n: number): BigDecimal | undefined => {
|
|
|
1893
1892
|
}
|
|
1894
1893
|
|
|
1895
1894
|
const [lead, trail = ""] = string.split(".")
|
|
1896
|
-
return make(BigInt(`${lead}${trail}`), trail.length)
|
|
1895
|
+
return Option.some(make(BigInt(`${lead}${trail}`), trail.length))
|
|
1897
1896
|
}
|
|
1898
1897
|
|
|
1899
1898
|
/**
|
|
@@ -1901,23 +1900,23 @@ export const fromNumber = (n: number): BigDecimal | undefined => {
|
|
|
1901
1900
|
*
|
|
1902
1901
|
* @example
|
|
1903
1902
|
* ```ts
|
|
1904
|
-
* import { BigDecimal } from "effect"
|
|
1903
|
+
* import { BigDecimal, Option } from "effect"
|
|
1905
1904
|
* import * as assert from "node:assert"
|
|
1906
1905
|
*
|
|
1907
|
-
* assert.deepStrictEqual(BigDecimal.fromString("123"), BigDecimal.make(123n, 0))
|
|
1906
|
+
* assert.deepStrictEqual(BigDecimal.fromString("123"), Option.some(BigDecimal.make(123n, 0)))
|
|
1908
1907
|
* assert.deepStrictEqual(
|
|
1909
1908
|
* BigDecimal.fromString("123.456"),
|
|
1910
|
-
* BigDecimal.make(123456n, 3)
|
|
1909
|
+
* Option.some(BigDecimal.make(123456n, 3))
|
|
1911
1910
|
* )
|
|
1912
|
-
* assert.deepStrictEqual(BigDecimal.fromString("123.abc"),
|
|
1911
|
+
* assert.deepStrictEqual(BigDecimal.fromString("123.abc"), Option.none())
|
|
1913
1912
|
* ```
|
|
1914
1913
|
*
|
|
1915
1914
|
* @since 2.0.0
|
|
1916
1915
|
* @category constructors
|
|
1917
1916
|
*/
|
|
1918
|
-
export const fromString = (s: string): BigDecimal
|
|
1917
|
+
export const fromString = (s: string): Option.Option<BigDecimal> => {
|
|
1919
1918
|
if (s === "") {
|
|
1920
|
-
return zero
|
|
1919
|
+
return Option.some(zero)
|
|
1921
1920
|
}
|
|
1922
1921
|
|
|
1923
1922
|
let base: string
|
|
@@ -1928,7 +1927,7 @@ export const fromString = (s: string): BigDecimal | undefined => {
|
|
|
1928
1927
|
base = s.slice(0, seperator)
|
|
1929
1928
|
exp = Number(trail)
|
|
1930
1929
|
if (base === "" || !Number.isSafeInteger(exp) || !FINITE_INT_REGEXP.test(trail)) {
|
|
1931
|
-
return
|
|
1930
|
+
return Option.none()
|
|
1932
1931
|
}
|
|
1933
1932
|
} else {
|
|
1934
1933
|
base = s
|
|
@@ -1949,15 +1948,15 @@ export const fromString = (s: string): BigDecimal | undefined => {
|
|
|
1949
1948
|
}
|
|
1950
1949
|
|
|
1951
1950
|
if (!FINITE_INT_REGEXP.test(digits)) {
|
|
1952
|
-
return
|
|
1951
|
+
return Option.none()
|
|
1953
1952
|
}
|
|
1954
1953
|
|
|
1955
1954
|
const scale = offset - exp
|
|
1956
1955
|
if (!Number.isSafeInteger(scale)) {
|
|
1957
|
-
return
|
|
1956
|
+
return Option.none()
|
|
1958
1957
|
}
|
|
1959
1958
|
|
|
1960
|
-
return make(BigInt(digits), scale)
|
|
1959
|
+
return Option.some(make(BigInt(digits), scale))
|
|
1961
1960
|
}
|
|
1962
1961
|
|
|
1963
1962
|
/**
|
|
@@ -1977,9 +1976,7 @@ export const fromString = (s: string): BigDecimal | undefined => {
|
|
|
1977
1976
|
* @category constructors
|
|
1978
1977
|
*/
|
|
1979
1978
|
export const fromStringUnsafe = (s: string): BigDecimal => {
|
|
1980
|
-
|
|
1981
|
-
if (out) return out
|
|
1982
|
-
throw new Error(`Invalid numerical string: ${s}`)
|
|
1979
|
+
return Option.getOrThrowWith(fromString(s), () => new Error(`Invalid numerical string: ${s}`))
|
|
1983
1980
|
}
|
|
1984
1981
|
|
|
1985
1982
|
/**
|
package/src/BigInt.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import * as Combiner from "./Combiner.ts"
|
|
9
9
|
import * as Equ from "./Equivalence.ts"
|
|
10
10
|
import { dual } from "./Function.ts"
|
|
11
|
+
import * as Option from "./Option.ts"
|
|
11
12
|
import * as order from "./Order.ts"
|
|
12
13
|
import type { Ordering } from "./Ordering.ts"
|
|
13
14
|
import * as predicate from "./Predicate.ts"
|
|
@@ -200,15 +201,17 @@ export const subtract: {
|
|
|
200
201
|
* If the dividend is not a multiple of the divisor the result will be a `bigint` value
|
|
201
202
|
* which represents the integer division rounded down to the nearest integer.
|
|
202
203
|
*
|
|
203
|
-
* Returns `
|
|
204
|
+
* Returns `Option.none()` if the divisor is `0n`.
|
|
204
205
|
*
|
|
205
206
|
* @example
|
|
206
207
|
* ```ts
|
|
207
208
|
* import { divide } from "effect/BigInt"
|
|
208
209
|
* import * as assert from "node:assert"
|
|
209
210
|
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
211
|
+
* import { Option } from "effect"
|
|
212
|
+
*
|
|
213
|
+
* assert.deepStrictEqual(divide(6n, 3n), Option.some(2n))
|
|
214
|
+
* assert.deepStrictEqual(divide(6n, 0n), Option.none())
|
|
212
215
|
* ```
|
|
213
216
|
*
|
|
214
217
|
* @category math
|
|
@@ -221,45 +224,49 @@ export const divide: {
|
|
|
221
224
|
* If the dividend is not a multiple of the divisor the result will be a `bigint` value
|
|
222
225
|
* which represents the integer division rounded down to the nearest integer.
|
|
223
226
|
*
|
|
224
|
-
* Returns `
|
|
227
|
+
* Returns `Option.none()` if the divisor is `0n`.
|
|
225
228
|
*
|
|
226
229
|
* @example
|
|
227
230
|
* ```ts
|
|
228
231
|
* import { divide } from "effect/BigInt"
|
|
229
232
|
* import * as assert from "node:assert"
|
|
230
233
|
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
234
|
+
* import { Option } from "effect"
|
|
235
|
+
*
|
|
236
|
+
* assert.deepStrictEqual(divide(6n, 3n), Option.some(2n))
|
|
237
|
+
* assert.deepStrictEqual(divide(6n, 0n), Option.none())
|
|
233
238
|
* ```
|
|
234
239
|
*
|
|
235
240
|
* @category math
|
|
236
241
|
* @since 2.0.0
|
|
237
242
|
*/
|
|
238
|
-
(that: bigint): (self: bigint) => bigint
|
|
243
|
+
(that: bigint): (self: bigint) => Option.Option<bigint>
|
|
239
244
|
/**
|
|
240
245
|
* Provides a division operation on `bigint`s.
|
|
241
246
|
*
|
|
242
247
|
* If the dividend is not a multiple of the divisor the result will be a `bigint` value
|
|
243
248
|
* which represents the integer division rounded down to the nearest integer.
|
|
244
249
|
*
|
|
245
|
-
* Returns `
|
|
250
|
+
* Returns `Option.none()` if the divisor is `0n`.
|
|
246
251
|
*
|
|
247
252
|
* @example
|
|
248
253
|
* ```ts
|
|
249
254
|
* import { divide } from "effect/BigInt"
|
|
250
255
|
* import * as assert from "node:assert"
|
|
251
256
|
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
257
|
+
* import { Option } from "effect"
|
|
258
|
+
*
|
|
259
|
+
* assert.deepStrictEqual(divide(6n, 3n), Option.some(2n))
|
|
260
|
+
* assert.deepStrictEqual(divide(6n, 0n), Option.none())
|
|
254
261
|
* ```
|
|
255
262
|
*
|
|
256
263
|
* @category math
|
|
257
264
|
* @since 2.0.0
|
|
258
265
|
*/
|
|
259
|
-
(self: bigint, that: bigint): bigint
|
|
266
|
+
(self: bigint, that: bigint): Option.Option<bigint>
|
|
260
267
|
} = dual(
|
|
261
268
|
2,
|
|
262
|
-
(self: bigint, that: bigint): bigint
|
|
269
|
+
(self: bigint, that: bigint): Option.Option<bigint> => that === bigint0 ? Option.none() : Option.some(self / that)
|
|
263
270
|
)
|
|
264
271
|
|
|
265
272
|
/**
|
|
@@ -1034,7 +1041,7 @@ export const sqrtUnsafe = (n: bigint): bigint => {
|
|
|
1034
1041
|
}
|
|
1035
1042
|
|
|
1036
1043
|
/**
|
|
1037
|
-
* Determines the square root of a given `bigint` safely. Returns `
|
|
1044
|
+
* Determines the square root of a given `bigint` safely. Returns `Option.none()` if
|
|
1038
1045
|
* the given `bigint` is negative.
|
|
1039
1046
|
*
|
|
1040
1047
|
* **Example**
|
|
@@ -1042,16 +1049,17 @@ export const sqrtUnsafe = (n: bigint): bigint => {
|
|
|
1042
1049
|
* ```ts
|
|
1043
1050
|
* import { BigInt } from "effect"
|
|
1044
1051
|
*
|
|
1045
|
-
* BigInt.sqrt(4n) // 2n
|
|
1046
|
-
* BigInt.sqrt(9n) // 3n
|
|
1047
|
-
* BigInt.sqrt(16n) // 4n
|
|
1048
|
-
* BigInt.sqrt(-1n) //
|
|
1052
|
+
* BigInt.sqrt(4n) // Option.some(2n)
|
|
1053
|
+
* BigInt.sqrt(9n) // Option.some(3n)
|
|
1054
|
+
* BigInt.sqrt(16n) // Option.some(4n)
|
|
1055
|
+
* BigInt.sqrt(-1n) // Option.none()
|
|
1049
1056
|
* ```
|
|
1050
1057
|
*
|
|
1051
1058
|
* @category math
|
|
1052
1059
|
* @since 2.0.0
|
|
1053
1060
|
*/
|
|
1054
|
-
export const sqrt = (n: bigint): bigint
|
|
1061
|
+
export const sqrt = (n: bigint): Option.Option<bigint> =>
|
|
1062
|
+
isGreaterThanOrEqualTo(n, bigint0) ? Option.some(sqrtUnsafe(n)) : Option.none()
|
|
1055
1063
|
|
|
1056
1064
|
/**
|
|
1057
1065
|
* Takes an `Iterable` of `bigint`s and returns their sum as a single `bigint
|
|
@@ -1104,52 +1112,52 @@ export const multiplyAll = (collection: Iterable<bigint>): bigint => {
|
|
|
1104
1112
|
* Converts a `bigint` to a `number`.
|
|
1105
1113
|
*
|
|
1106
1114
|
* If the `bigint` is outside the safe integer range for JavaScript (`Number.MAX_SAFE_INTEGER`
|
|
1107
|
-
* and `Number.MIN_SAFE_INTEGER`), it returns `
|
|
1115
|
+
* and `Number.MIN_SAFE_INTEGER`), it returns `Option.none()`.
|
|
1108
1116
|
*
|
|
1109
1117
|
* @example
|
|
1110
1118
|
* ```ts
|
|
1111
1119
|
* import { BigInt as BI } from "effect"
|
|
1112
1120
|
*
|
|
1113
|
-
* BI.toNumber(42n) // 42
|
|
1114
|
-
* BI.toNumber(BigInt(Number.MAX_SAFE_INTEGER) + 1n) //
|
|
1115
|
-
* BI.toNumber(BigInt(Number.MIN_SAFE_INTEGER) - 1n) //
|
|
1121
|
+
* BI.toNumber(42n) // Option.some(42)
|
|
1122
|
+
* BI.toNumber(BigInt(Number.MAX_SAFE_INTEGER) + 1n) // Option.none()
|
|
1123
|
+
* BI.toNumber(BigInt(Number.MIN_SAFE_INTEGER) - 1n) // Option.none()
|
|
1116
1124
|
* ```
|
|
1117
1125
|
*
|
|
1118
1126
|
* @category conversions
|
|
1119
1127
|
* @since 2.0.0
|
|
1120
1128
|
*/
|
|
1121
|
-
export const toNumber = (b: bigint): number
|
|
1129
|
+
export const toNumber = (b: bigint): Option.Option<number> => {
|
|
1122
1130
|
if (b > BigInt(Number.MAX_SAFE_INTEGER) || b < BigInt(Number.MIN_SAFE_INTEGER)) {
|
|
1123
|
-
return
|
|
1131
|
+
return Option.none()
|
|
1124
1132
|
}
|
|
1125
|
-
return Number(b)
|
|
1133
|
+
return Option.some(Number(b))
|
|
1126
1134
|
}
|
|
1127
1135
|
|
|
1128
1136
|
/**
|
|
1129
1137
|
* Converts a string to a `bigint`.
|
|
1130
1138
|
*
|
|
1131
1139
|
* If the string is empty or contains characters that cannot be converted into a
|
|
1132
|
-
* `bigint`, it returns `
|
|
1140
|
+
* `bigint`, it returns `Option.none()`.
|
|
1133
1141
|
*
|
|
1134
1142
|
* @example
|
|
1135
1143
|
* ```ts
|
|
1136
1144
|
* import { BigInt } from "effect"
|
|
1137
1145
|
*
|
|
1138
|
-
* BigInt.fromString("42") // 42n
|
|
1139
|
-
* BigInt.fromString(" ") //
|
|
1140
|
-
* BigInt.fromString("a") //
|
|
1146
|
+
* BigInt.fromString("42") // Option.some(42n)
|
|
1147
|
+
* BigInt.fromString(" ") // Option.none()
|
|
1148
|
+
* BigInt.fromString("a") // Option.none()
|
|
1141
1149
|
* ```
|
|
1142
1150
|
*
|
|
1143
1151
|
* @category conversions
|
|
1144
1152
|
* @since 2.4.12
|
|
1145
1153
|
*/
|
|
1146
|
-
export const fromString = (s: string): bigint
|
|
1154
|
+
export const fromString = (s: string): Option.Option<bigint> => {
|
|
1147
1155
|
try {
|
|
1148
1156
|
return s.trim() === ""
|
|
1149
|
-
?
|
|
1150
|
-
: BigInt(s)
|
|
1157
|
+
? Option.none()
|
|
1158
|
+
: Option.some(BigInt(s))
|
|
1151
1159
|
} catch {
|
|
1152
|
-
return
|
|
1160
|
+
return Option.none()
|
|
1153
1161
|
}
|
|
1154
1162
|
}
|
|
1155
1163
|
|
|
@@ -1158,30 +1166,30 @@ export const fromString = (s: string): bigint | undefined => {
|
|
|
1158
1166
|
*
|
|
1159
1167
|
* If the number is outside the safe integer range for JavaScript
|
|
1160
1168
|
* (`Number.MAX_SAFE_INTEGER` and `Number.MIN_SAFE_INTEGER`) or if the number is
|
|
1161
|
-
* not a valid `bigint`, it returns `
|
|
1169
|
+
* not a valid `bigint`, it returns `Option.none()`.
|
|
1162
1170
|
*
|
|
1163
1171
|
* @example
|
|
1164
1172
|
* ```ts
|
|
1165
1173
|
* import { BigInt } from "effect"
|
|
1166
1174
|
*
|
|
1167
|
-
* BigInt.fromNumber(42) // 42n
|
|
1175
|
+
* BigInt.fromNumber(42) // Option.some(42n)
|
|
1168
1176
|
*
|
|
1169
|
-
* BigInt.fromNumber(Number.MAX_SAFE_INTEGER + 1) //
|
|
1170
|
-
* BigInt.fromNumber(Number.MIN_SAFE_INTEGER - 1) //
|
|
1177
|
+
* BigInt.fromNumber(Number.MAX_SAFE_INTEGER + 1) // Option.none()
|
|
1178
|
+
* BigInt.fromNumber(Number.MIN_SAFE_INTEGER - 1) // Option.none()
|
|
1171
1179
|
* ```
|
|
1172
1180
|
*
|
|
1173
1181
|
* @category conversions
|
|
1174
1182
|
* @since 2.4.12
|
|
1175
1183
|
*/
|
|
1176
|
-
export function fromNumber(n: number): bigint
|
|
1184
|
+
export function fromNumber(n: number): Option.Option<bigint> {
|
|
1177
1185
|
if (n > Number.MAX_SAFE_INTEGER || n < Number.MIN_SAFE_INTEGER) {
|
|
1178
|
-
return
|
|
1186
|
+
return Option.none()
|
|
1179
1187
|
}
|
|
1180
1188
|
|
|
1181
1189
|
try {
|
|
1182
|
-
return BigInt(n)
|
|
1190
|
+
return Option.some(BigInt(n))
|
|
1183
1191
|
} catch {
|
|
1184
|
-
return
|
|
1192
|
+
return Option.none()
|
|
1185
1193
|
}
|
|
1186
1194
|
}
|
|
1187
1195
|
|