@reactivex/ix-esnext-esm
Version:
The Interactive Extensions for JavaScript
1 lines • 2.23 kB
Source Map (JSON)
{"version":3,"sources":["iterable/operators/repeat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,MAAM,OAAO,cAAwB,SAAQ,SAAkB;IAI7D,YAAY,MAAyB,EAAE,KAAa;QAClD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QAChB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE;YACtB,OAAO,CAAC,EAAE;gBACR,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;oBAC/B,MAAM,IAAI,CAAC;iBACZ;aACF;SACF;aAAM;YACL,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACpC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;oBAC/B,MAAM,IAAI,CAAC;iBACZ;aACF;SACF;IACH,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAU,QAAgB,CAAC,CAAC;IAChD,OAAO,SAAS,sBAAsB,CAAC,MAAyB;QAC9D,OAAO,IAAI,cAAc,CAAU,MAAM,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC,CAAC;AACJ,CAAC","file":"repeat.js","sourcesContent":["import { IterableX } from '../iterablex';\nimport { MonoTypeOperatorFunction } from '../../interfaces';\n\nexport class RepeatIterable<TSource> extends IterableX<TSource> {\n private _source: Iterable<TSource>;\n private _count: number;\n\n constructor(source: Iterable<TSource>, count: number) {\n super();\n this._source = source;\n this._count = count;\n }\n\n *[Symbol.iterator]() {\n if (this._count === -1) {\n while (1) {\n for (const item of this._source) {\n yield item;\n }\n }\n } else {\n for (let i = 0; i < this._count; i++) {\n for (const item of this._source) {\n yield item;\n }\n }\n }\n }\n}\n\n/**\n * Repeats the async-enumerable sequence a specified number of times.\n *\n * @export\n * @template TSource The type of the elements in the source sequence.\n * @param {number} [count=-1] Number of times to repeat the sequence. If not specified, the sequence repeats indefinitely.\n * @returns {MonoTypeOperatorFunction<TSource>} The iterable sequence producing the elements of the given sequence repeatedly.\n */\nexport function repeat<TSource>(count: number = -1): MonoTypeOperatorFunction<TSource> {\n return function repeatOperatorFunction(source: Iterable<TSource>): IterableX<TSource> {\n return new RepeatIterable<TSource>(source, count);\n };\n}\n"]}