effect@3.12.8
Patch Changes
-
#4341
766113cThanks @fubhy! - ImproveDuration.decodeHandling of High-Resolution Time- Ensured Immutability: Added the
readonlymodifier to[seconds: number, nanos: number]inDurationInputto prevent accidental modifications. - Better Edge Case Handling: Now correctly processes special values like
-InfinityandNaNwhen they appear in the tuple representation of duration.
- Ensured Immutability: Added the
-
#4333
712277fThanks @gcanti! - Cron:unsafeParsenow throws a more informative error instead of a generic one -
#4387
f269122Thanks @KhraksMamtsov! - A more precise signature has been applied forEffect.schedule -
#4351
430c846Thanks @tim-smart! - fix Layer.scope types to correctly use the Scope tag identifier -
#4313
a9c94c8Thanks @gcanti! - Schema: UpdateDurationEncoding to a Tagged Union Format.This changeset fixes the
Durationschema to support all possible duration types, including finite, infinite, and nanosecond durations. The encoding format has been updated from a tuple (readonly [seconds: number, nanos: number]) to a tagged union.This update introduces a change to the encoding format. The previous tuple representation is replaced with a more expressive tagged union, which accommodates all duration types:
type DurationEncoded = | { readonly _tag: "Millis" readonly millis: number } | { readonly _tag: "Nanos" readonly nanos: string } | { readonly _tag: "Infinity" }
Rationale
The
Durationschema is primarily used to encode durations for transmission. The new tagged union format ensures clear and precise encoding for:- Finite durations, such as milliseconds.
- Infinite durations, such as
Duration.infinity. - Nanosecond durations.
Example
import { Duration, Schema } from "effect" // Encoding a finite duration in milliseconds console.log(Schema.encodeSync(Schema.Duration)(Duration.millis(1000))) // Output: { _tag: 'Millis', millis: 1000 } // Encoding an infinite duration console.log(Schema.encodeSync(Schema.Duration)(Duration.infinity)) // Output: { _tag: 'Infinity' } // Encoding a duration in nanoseconds console.log(Schema.encodeSync(Schema.Duration)(Duration.nanos(1000n))) // Output: { _tag: 'Nanos', nanos: '1000' }
-
#4331
107e6f0Thanks @gcanti! - Schema: Improve encoding inDefectand add test for array-based defects. -
#4329
65c11b9Thanks @gcanti! - Schema: UpdateitemsCountto allow0as a valid argument, closes #4328. -
#4330
e386d2fThanks @gcanti! - Add missing overload forOption.as. -
#4352
9172efbThanks @tim-smart! - optimize Stream.toReadableStream