// ets_tracing: off import * as P from "../../../../Promise/index.js" import type * as C from "../core.js" import * as InterruptWhen from "./interruptWhen.js" /** * Returns a new channel, which is the same as this one, except it will be interrupted when the * specified promise is completed. If the promise is completed before the underlying channel is * done, then the returned channel will yield the value of the promise. Otherwise, if the * underlying channel finishes first, then the returned channel will yield the value of the * underlying channel. */ export function interruptWhenP_< Env, InErr, InElem, InDone, OutErr, OutErr1, OutElem, OutDone, OutDone1 >( self: C.Channel, promise: P.Promise ): C.Channel< Env, InErr, InElem, InDone, OutErr | OutErr1, OutElem, OutDone | OutDone1 > { return InterruptWhen.interruptWhen_(self, P.await(promise)) } /** * Returns a new channel, which is the same as this one, except it will be interrupted when the * specified promise is completed. If the promise is completed before the underlying channel is * done, then the returned channel will yield the value of the promise. Otherwise, if the * underlying channel finishes first, then the returned channel will yield the value of the * underlying channel. * * @ets_data_first interruptWhenP_ */ export function interruptWhenP( promise: P.Promise ) { return ( self: C.Channel ) => interruptWhenP_(self, promise) }