UNPKG

1.55 kBSource Map (JSON)View Raw
1{"version":3,"sources":["asynciterable/takeuntil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,OAAO,sBAAgC,SAAQ,cAAuB;IAI1E,YAAY,MAA8B,EAAE,KAAyB;QACnE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC;QAC7C,IAAI,KAAK,EAAE,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;YACnC,IAAI,SAAS,EAAE;gBACb,MAAM;aACP;YACD,MAAM,IAAI,CAAC;SACZ;IACH,CAAC;CACF;AAED,MAAM,UAAU,SAAS,CACvB,MAA8B,EAC9B,KAAyB;IAEzB,OAAO,IAAI,sBAAsB,CAAU,MAAM,EAAE,KAAK,CAAC,CAAC;AAC5D,CAAC","file":"takeuntil.js","sourcesContent":["import { AsyncIterableX } from './asynciterablex';\n\nexport class TakeUntilAsyncIterable<TSource> extends AsyncIterableX<TSource> {\n private _source: AsyncIterable<TSource>;\n private _other: () => Promise<any>;\n\n constructor(source: AsyncIterable<TSource>, other: () => Promise<any>) {\n super();\n this._source = source;\n this._other = other;\n }\n\n async *[Symbol.asyncIterator]() {\n let otherDone = false;\n this._other().then(() => (otherDone = true));\n for await (let item of this._source) {\n if (otherDone) {\n break;\n }\n yield item;\n }\n }\n}\n\nexport function takeUntil<TSource>(\n source: AsyncIterable<TSource>,\n other: () => Promise<any>\n): AsyncIterableX<TSource> {\n return new TakeUntilAsyncIterable<TSource>(source, other);\n}\n"]}
\No newline at end of file