MCPcopy Index your code
hub / github.com/Effect-TS/effect / toHrTime

Function toHrTime

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

Source from the content-addressed store, hash-verified

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

Callers 1

toJSONFunction · 0.85

Calls 2

NumberInterface · 0.85
decodeFunction · 0.70

Tested by

no test coverage detected