import { AsyncIterableX } from './asynciterablex' ; import { defer } from './defer' ; import { empty } from './empty' ; template TSource param { ( ( signal ? : AbortSignal ) => boolean | Promise < boolean > ) } condition param { AsyncIterable < TSource > } thenSource param { AsyncIterable < TSource > } elseSource returns { AsyncIterableX < TSource > } export function iif < TSource > ( condition , thenSource , elseSource = empty ( ) ) { return defer < TSource > ( async ( signal ) => ( ( await condition ( signal ) ) ? thenSource : elseSource ) ) ; }