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

Function make

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

Source from the content-addressed store, hash-verified

185} as const
186
187const make = (input: number | bigint): Duration => {
188 const duration = Object.create(DurationProto)
189 if (isNumber(input)) {
190 if (isNaN(input) || input <= 0) {
191 duration.value = zeroValue
192 } else if (!Number.isFinite(input)) {
193 duration.value = infinityValue
194 } else if (!Number.isInteger(input)) {
195 duration.value = { _tag: "Nanos", nanos: BigInt(Math.round(input * 1_000_000)) }
196 } else {
197 duration.value = { _tag: "Millis", millis: input }
198 }
199 } else if (input <= bigint0) {
200 duration.value = zeroValue
201 } else {
202 duration.value = { _tag: "Nanos", nanos: input }
203 }
204 return duration
205}
206
207/**
208 * @since 2.0.0

Callers 9

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

isNumberFunction · 0.85
createMethod · 0.80

Tested by

no test coverage detected