MCPcopy Create free account
hub / github.com/Effect-TS/effect / fromMillisString

Function fromMillisString

packages/effect/src/Duration.ts:77–83  ·  view source on GitHub ↗
(input: string, scale: number)

Source from the content-addressed store, hash-verified

75}
76
77const fromMillisString = (input: string, scale: number): Duration => {
78 const millis = Number(input) * scale
79 if (!Number.isFinite(millis)) return make(millis)
80 const nanos = parseNanos(input, BigInt(scale) * bigint1e6)
81 // Keep the millisecond representation only when it preserves the exact value.
82 return make(Number.isInteger(millis) && BigInt(millis) * bigint1e6 === nanos ? millis : nanos)
83}
84
85const nanosToHrTime = (nanos: bigint): [seconds: number, nanos: number] => {
86 const sign = nanos < bigint0 ? -bigint1 : bigint1

Callers 1

fromInputUnsafeFunction · 0.85

Calls 4

parseNanosFunction · 0.85
NumberFunction · 0.70
makeFunction · 0.70
BigIntInterface · 0.70

Tested by

no test coverage detected