@reactivex/ix-esnext-esm
Version:
The Interactive Extensions for JavaScript
1 lines • 1.92 kB
Source Map (JSON)
{"version":3,"sources":["asynciterable/operators/repeat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,MAAM,OAAO,mBAA6B,SAAQ,cAAuB;IAIvE,YAAY,MAA8B,EAAE,KAAa;QACvD,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,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE;YACtB,OAAO,CAAC,EAAE;gBACR,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;oBACrC,MAAM,IAAI,CAAC;iBACZ;aACF;SACF;aAAM;YACL,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACpC,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;oBACrC,MAAM,IAAI,CAAC;iBACZ;aACF;SACF;IACH,CAAC;CACF;AAED,MAAM,UAAU,MAAM,CAAU,QAAgB,CAAC,CAAC;IAChD,OAAO,SAAS,sBAAsB,CAAC,MAA8B;QACnE,OAAO,IAAI,mBAAmB,CAAU,MAAM,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC,CAAC;AACJ,CAAC","file":"repeat.js","sourcesContent":["import { AsyncIterableX } from '../asynciterablex';\nimport { MonoTypeOperatorAsyncFunction } from '../../interfaces';\n\nexport class RepeatAsyncIterable<TSource> extends AsyncIterableX<TSource> {\n private _source: AsyncIterable<TSource>;\n private _count: number;\n\n constructor(source: AsyncIterable<TSource>, count: number) {\n super();\n this._source = source;\n this._count = count;\n }\n\n async *[Symbol.asyncIterator]() {\n if (this._count === -1) {\n while (1) {\n for await (const item of this._source) {\n yield item;\n }\n }\n } else {\n for (let i = 0; i < this._count; i++) {\n for await (const item of this._source) {\n yield item;\n }\n }\n }\n }\n}\n\nexport function repeat<TSource>(count: number = -1): MonoTypeOperatorAsyncFunction<TSource> {\n return function repeatOperatorFunction(source: AsyncIterable<TSource>): AsyncIterableX<TSource> {\n return new RepeatAsyncIterable<TSource>(source, count);\n };\n}\n"]}