1 | import { defer } from './defer';
|
2 | import { empty } from './empty';
|
3 | /**
|
4 | * If the specified condition evaluates true, select the thenSource sequence.
|
5 | * Otherwise, select the elseSource sequence.
|
6 | *
|
7 | * @export
|
8 | * @template TSource The type of the elements in the result sequence.
|
9 | * @param {((signal?: AbortSignal) => boolean | Promise<boolean>)} condition Condition evaluated to decide which sequence to return.
|
10 | * @param {AsyncIterable<TSource>} thenSource Sequence returned in case evaluates true.
|
11 | * @param {AsyncIterable<TSource>} [elseSource=empty()] Sequence returned in case condition evaluates false.
|
12 | * @returns {AsyncIterableX<TSource>} thenSource if condition evaluates true; elseSource otherwise.
|
13 | */
|
14 | export function iif(condition, thenSource, elseSource = empty()) {
|
15 | return defer(async (signal) => ((await condition(signal)) ? thenSource : elseSource));
|
16 | }
|
17 |
|
18 | //# sourceMappingURL=iif.mjs.map
|