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

Function toHrTime

packages/effect/src/Duration.ts:401–417  ·  view source on GitHub ↗
(self: DurationInput)

Source from the content-addressed store, hash-verified

399 * @category getters
400 */
401export const toHrTime = (self: DurationInput): [seconds: number, nanos: number] => {
402 const _self = decode(self)
403 switch (_self.value._tag) {
404 case "Infinity":
405 return [Infinity, 0]
406 case "Nanos":
407 return [
408 Number(_self.value.nanos / bigint1e9),
409 Number(_self.value.nanos % bigint1e9)
410 ]
411 case "Millis":
412 return [
413 Math.floor(_self.value.millis / 1000),
414 Math.round((_self.value.millis % 1000) * 1_000_000)
415 ]
416 }
417}
418
419/**
420 * @since 2.0.0

Callers 1

toJSONFunction · 0.85

Calls 2

NumberInterface · 0.85
decodeFunction · 0.70

Tested by

no test coverage detected