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

Function secondOfMinute

packages/effect/src/internal/schedule.ts:1370–1395  ·  view source on GitHub ↗
(second: number)

Source from the content-addressed store, hash-verified

1368
1369/** @internal */
1370export const secondOfMinute = (second: number): Schedule.Schedule<number> =>
1371 makeWithState<[number, number], unknown, number>(
1372 [Number.NEGATIVE_INFINITY, 0],
1373 (now, _, state) => {
1374 if (!Number.isInteger(second) || second < 0 || 59 < second) {
1375 return core.dieSync(() =>
1376 new core.IllegalArgumentException(
1377 `Invalid argument in: secondOfMinute(${second}). Must be in range 0...59`
1378 )
1379 )
1380 }
1381 const n = state[1]
1382 const initial = n === 0
1383 const second0 = nextSecond(now, second, initial)
1384 const start = beginningOfSecond(second0)
1385 const end = endOfSecond(second0)
1386 const interval = Interval.make(start, end)
1387 return core.succeed(
1388 [
1389 [end, n + 1],
1390 n,
1391 ScheduleDecision.continueWith(interval)
1392 ]
1393 )
1394 }
1395 )
1396
1397/** @internal */
1398export const spaced = (duration: Duration.DurationInput): Schedule.Schedule<number> => addDelay(forever, () => duration)

Callers

nothing calls this directly

Calls 5

makeWithStateFunction · 0.85
nextSecondFunction · 0.85
beginningOfSecondFunction · 0.85
endOfSecondFunction · 0.85
makeMethod · 0.65

Tested by

no test coverage detected