milliseconds, possibly fractional
seconds, possibly fractional
the base-unit form, e.g. "500000000ns" -- valid CASC if fed back in
StaticfromStaticfromStaticparseParses duration literal text ("1h30m", "1.5s"), with the same rules
and errors as a bare literal in a CASC file.
A CASC duration (CASC.md ยง6.8) --
500ms,1h30m,!duration("5m"). Mirrors the Elixir implementation's{:duration, nanoseconds}: nanoseconds are the base unit, held as abigintso that every literal the spec allows is represented exactly (a few hundred days already exceedsNumber.MAX_SAFE_INTEGERnanoseconds).JS has no native duration type (
Temporalisn't broadly available), so the conversion helpers target plain numbers:toMilliseconds()(whatsetTimeoutand most Node APIs take),toSeconds(), and the matchingDuration.fromMilliseconds()/fromSeconds()constructors.