UNPKG

1.33 kBSource Map (JSON)View Raw
1{"version":3,"sources":["iterable/iif.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,GAAG,CACjB,EAAiB,EACjB,UAA6B,EAC7B,aAAgC,KAAK,EAAE;IAEvC,OAAO,KAAK,CAAU,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;AAChE,CAAC","file":"iif.js","sourcesContent":["import { IterableX } from './iterablex';\nimport { defer } from './defer';\nimport { empty } from './empty';\n\n/**\n * If the specified condition evaluates true, select the thenSource sequence.\n * Otherwise, select the elseSource sequence.\n *\n * @export\n * @template TSource The type of the elements in the result sequence.\n * @param {(() => boolean)} condition Condition evaluated to decide which sequence to return.\n * @param {Iterable<TSource>} thenSource Sequence returned in case evaluates true.\n * @param {Iterable<TSource>} [elseSource=empty()] Sequence returned in case condition evaluates false.\n * @returns {IterableX<TSource>} thenSource if condition evaluates true; elseSource otherwise.\n */\nexport function iif<TSource>(\n fn: () => boolean,\n thenSource: Iterable<TSource>,\n elseSource: Iterable<TSource> = empty()\n): IterableX<TSource> {\n return defer<TSource>(() => (fn() ? thenSource : elseSource));\n}\n"]}
\No newline at end of file