( schedule: Schedule<Output, Input, Error, Env> )
| 375 | * @since 4.0.0 |
| 376 | */ |
| 377 | export const toStepWithMetadata = <Output, Input, Error, Env>( |
| 378 | schedule: Schedule<Output, Input, Error, Env> |
| 379 | ): Effect< |
| 380 | (input: Input) => Pull.Pull<Metadata<Output, Input>, Error, Output, Env>, |
| 381 | never, |
| 382 | Env |
| 383 | > => |
| 384 | effect.clockWith((clock) => |
| 385 | effect.map( |
| 386 | toStep(schedule), |
| 387 | (step) => { |
| 388 | const metaFn = metadataFn() |
| 389 | return (input) => |
| 390 | effect.suspend(() => { |
| 391 | const now = clock.currentTimeMillisUnsafe() |
| 392 | return effect.flatMap( |
| 393 | step(now, input), |
| 394 | ([output, duration]) => { |
| 395 | const meta = metaFn(now, input) as Mutable<Metadata<Output, Input>> |
| 396 | meta.output = output |
| 397 | meta.duration = duration |
| 398 | return effect.as(effect.sleep(duration), meta) |
| 399 | } |
| 400 | ) |
| 401 | }) |
| 402 | } |
| 403 | ) |
| 404 | ) |
| 405 | |
| 406 | /** |
| 407 | * Extracts a step function from a Schedule that automatically handles sleep delays. |
no test coverage detected