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

Function secondOfMinute

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

Source from the content-addressed store, hash-verified

1376
1377/** @internal */
1378export const secondOfMinute = (second: number): Schedule.Schedule<number> =>
1379 makeWithState<[number, number], unknown, number>(
1380 [Number.NEGATIVE_INFINITY, 0],
1381 (now, _, state) => {
1382 if (!Number.isInteger(second) || second < 0 || 59 < second) {
1383 return core.dieSync(() =>
1384 new core.IllegalArgumentException(
1385 `Invalid argument in: secondOfMinute(${second}). Must be in range 0...59`
1386 )
1387 )
1388 }
1389 const n = state[1]
1390 const initial = n === 0
1391 const second0 = nextSecond(now, second, initial)
1392 const start = beginningOfSecond(second0)
1393 const end = endOfSecond(second0)
1394 const interval = Interval.make(start, end)
1395 return core.succeed(
1396 [
1397 [end, n + 1],
1398 n,
1399 ScheduleDecision.continueWith(interval)
1400 ]
1401 )
1402 }
1403 )
1404
1405/** @internal */
1406export 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