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

Method run

packages/effect/src/TestClock.ts:392–432  ·  view source on GitHub ↗

* Runs all effects scheduled to occur on or before the specified instant, * which may depend on the current time, in order.

(f: (instant: number) => number)

Source from the content-addressed store, hash-verified

390 * which may depend on the current time, in order.
391 */
392 run(f: (instant: number) => number): Effect.Effect<void> {
393 return pipe(
394 this.awaitSuspended(),
395 core.zipRight(pipe(
396 ref.modify(this.clockState, (data) => {
397 const end = f(data.instant)
398 const sorted = pipe(
399 data.sleeps,
400 Chunk.sort<readonly [number, Deferred.Deferred<void>]>(
401 pipe(number.Order, Order.mapInput((_) => _[0]))
402 )
403 )
404 if (Chunk.isNonEmpty(sorted)) {
405 const [instant, deferred] = Chunk.headNonEmpty(sorted)
406 if (instant <= end) {
407 return [
408 Option.some([end, deferred] as const),
409 makeData(instant, Chunk.tailNonEmpty(sorted))
410 ] as const
411 }
412 }
413 return [Option.none(), makeData(end, data.sleeps)] as const
414 }),
415 core.flatMap((option) => {
416 switch (option._tag) {
417 case "None": {
418 return core.void
419 }
420 case "Some": {
421 const [end, deferred] = option.value
422 return pipe(
423 core.deferredSucceed(deferred, void 0),
424 core.zipRight(core.yieldNow()),
425 core.zipRight(this.run(() => end))
426 )
427 }
428 }
429 })
430 ))
431 )
432 }
433}
434
435/**

Callers 15

setTimeMethod · 0.95
adjustMethod · 0.95
Command.test.tsFile · 0.45
Wizard.test.tsFile · 0.45
CliApp.test.tsFile · 0.45
command.tsFile · 0.45
parseInternalFunction · 0.45
prompt.tsFile · 0.45
minigit.tsFile · 0.45
naval-fate.tsFile · 0.45
McpServer.tsFile · 0.45
RpcServer.tsFile · 0.45

Calls 5

awaitSuspendedMethod · 0.95
makeDataFunction · 0.85
pipeFunction · 0.70
fFunction · 0.70
modifyMethod · 0.65

Tested by 7

runRequestFunction · 0.36
checkDelaysFunction · 0.36
checkRepetitionsFunction · 0.36
runSinkFunction · 0.36
sinkRaceLawFunction · 0.36
programFunction · 0.36
zipParLawFunction · 0.36