import * as tsplus_module_1 from "@effect/core/stream/Channel/operations/failCause";
import { ContinuationK, Fold } from "@effect/core/stream/Channel/definition/primitives";
/**
 * Returns a new channel, which sequentially combines this channel, together
 * with the provided factory function, which creates a second channel based on
 * the terminal value of this channel. The result is a channel that will first
 * perform the functions of this channel, before performing the functions of
 * the created channel (including yielding its terminal value).
 *
 * @tsplus fluent ets/Channel flatMap
 */

export function flatMap_(self, f) {
  return new Fold(self, new ContinuationK(f, cause => tsplus_module_1.failCause(() => cause)));
}
/**
 * Returns a new channel, which sequentially combines this channel, together
 * with the provided factory function, which creates a second channel based on
 * the terminal value of this channel. The result is a channel that will first
 * perform the functions of this channel, before performing the functions of
 * the created channel (including yielding its terminal value).
 *
 * @tsplus static ets/Channel/Aspects flatMap
 */

export const flatMap = f => self => flatMap_(self, f);
//# sourceMappingURL=flatMap.mjs.map