( all: Iterable<Eff> )
| 1456 | * @category sequencing |
| 1457 | */ |
| 1458 | export const raceAllFirst = <Eff extends Micro<any, any, any>>( |
| 1459 | all: Iterable<Eff> |
| 1460 | ): Micro<Micro.Success<Eff>, Micro.Error<Eff>, Micro.Context<Eff>> => |
| 1461 | withMicroFiber((parent) => |
| 1462 | async((resume) => { |
| 1463 | let done = false |
| 1464 | const fibers = new Set<MicroFiber<any, any>>() |
| 1465 | const onExit = (exit: MicroExit<any, any>) => { |
| 1466 | done = true |
| 1467 | resume(fibers.size === 0 ? exit : flatMap(fiberInterruptAll(fibers), () => exit)) |
| 1468 | } |
| 1469 | |
| 1470 | for (const effect of all) { |
| 1471 | if (done) break |
| 1472 | const fiber = unsafeFork(parent, interruptible(effect), true, true) |
| 1473 | fibers.add(fiber) |
| 1474 | fiber.addObserver((exit) => { |
| 1475 | fibers.delete(fiber) |
| 1476 | onExit(exit) |
| 1477 | }) |
| 1478 | } |
| 1479 | |
| 1480 | return fiberInterruptAll(fibers) |
| 1481 | }) |
| 1482 | ) |
| 1483 | |
| 1484 | /** |
| 1485 | * Returns an effect that races two effects, yielding the value of the first |
no test coverage detected