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

Function make

packages/effect/src/Duration.ts:402–420  ·  view source on GitHub ↗
(input: number | bigint)

Source from the content-addressed store, hash-verified

400} as const
401
402const make = (input: number | bigint): Duration => {
403 const duration = Object.create(DurationProto)
404 if (typeof input === "number") {
405 if (isNaN(input) || input === 0 || Object.is(input, -0)) {
406 duration.value = zeroDurationValue
407 } else if (!Number.isFinite(input)) {
408 duration.value = input > 0 ? infinityDurationValue : negativeInfinityDurationValue
409 } else if (!Number.isInteger(input)) {
410 duration.value = { _tag: "Nanos", nanos: roundMillisToNanos(input) }
411 } else {
412 duration.value = { _tag: "Millis", millis: input }
413 }
414 } else if (input === bigint0) {
415 duration.value = zeroDurationValue
416 } else {
417 duration.value = { _tag: "Nanos", nanos: input }
418 }
419 return duration
420}
421
422/**
423 * Checks whether a value is a Duration.

Callers 12

fromInputUnsafeFunction · 0.70
absFunction · 0.70
negateFunction · 0.70
Duration.tsFile · 0.70
nanosFunction · 0.70
microsFunction · 0.70
millisFunction · 0.70
secondsFunction · 0.70
minutesFunction · 0.70
hoursFunction · 0.70
daysFunction · 0.70
weeksFunction · 0.70

Calls 2

roundMillisToNanosFunction · 0.85
isMethod · 0.65

Tested by

no test coverage detected