import { makeSynthetic } from "@effect/core/io/Fiber/definition" /** * Effectually maps over the value the fiber computes. * * @tsplus static effect/core/io/Fiber.Aspects mapEffect * @tsplus static effect/core/io/RuntimeFiber.Aspects mapEffect * @tsplus pipeable effect/core/io/Fiber mapEffect * @tsplus pipeable effect/core/io/RuntimeFiber mapEffect */ export function mapEffect( f: (a: A) => Effect ) { return (self: Fiber): Fiber => makeSynthetic({ id: self.id, await: self.await.flatMap((_) => _.forEach(f)), children: self.children, inheritAll: self.inheritAll, poll: self.poll.flatMap((_) => _.fold( () => Effect.succeed(Maybe.none), (exit) => exit.forEach(f).map(Maybe.some) ) ), interruptAsFork: (id) => self.interruptAsFork(id) }) }