( schedule: Schedule<Output, Input, Error, Env> )
| 390 | * @since 4.0.0 |
| 391 | */ |
| 392 | export const toStepWithMetadata = <Output, Input, Error, Env>( |
| 393 | schedule: Schedule<Output, Input, Error, Env> |
| 394 | ): Effect< |
| 395 | (input: Input) => Pull.Pull<Metadata<Output, Input>, Error, Output, Env>, |
| 396 | never, |
| 397 | Env |
| 398 | > => |
| 399 | effect.clockWith((clock) => |
| 400 | effect.map( |
| 401 | toStep(schedule), |
| 402 | (step) => { |
| 403 | const metaFn = metadataFn() |
| 404 | return (input) => |
| 405 | effect.suspend(() => { |
| 406 | const now = clock.currentTimeMillisUnsafe() |
| 407 | return effect.flatMap( |
| 408 | step(now, input), |
| 409 | ([output, duration]) => { |
| 410 | const meta = metaFn(now, input) as Mutable<Metadata<Output, Input>> |
| 411 | meta.output = output |
| 412 | meta.duration = duration |
| 413 | return effect.as(effect.sleep(duration), meta) |
| 414 | } |
| 415 | ) |
| 416 | }) |
| 417 | } |
| 418 | ) |
| 419 | ) |
| 420 | |
| 421 | /** |
| 422 | * Extracts a step function from a Schedule that automatically handles sleep delays. |
no test coverage detected