You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
3.6 KiB
1 line
3.6 KiB
2 years ago
|
{"version":3,"file":"repeat.js","sourceRoot":"","sources":["../../src/operators/repeat.ts"],"names":[],"mappings":";;;;;;AACA,2BAA2B,eAAe,CAAC,CAAA;AAE3C,gCAAgC,+BAA+B,CAAC,CAAA;AAIhE;;;;;;;;;;;GAWG;AACH,gBAA0B,KAAkB;IAAlB,qBAAkB,GAAlB,SAAiB,CAAC;IAC1C,MAAM,CAAC,UAAC,MAAqB;QAC3B,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;YAChB,MAAM,CAAC,IAAI,iCAAe,EAAK,CAAC;QAClC,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;YACrB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QACrD,CAAC;QAAC,IAAI,CAAC,CAAC;YACN,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,KAAK,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAVe,cAAM,SAUrB,CAAA;AAED;IACE,wBAAoB,KAAa,EACb,MAAqB;QADrB,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAAe;IACzC,CAAC;IACD,6BAAI,GAAJ,UAAK,UAAyB,EAAE,MAAW;QACzC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF,CAAC;IACH,qBAAC;AAAD,CAAC,AAPD,IAOC;AAED;;;;GAIG;AACH;IAAkC,oCAAa;IAC7C,0BAAY,WAA4B,EACpB,KAAa,EACb,MAAqB;QACvC,kBAAM,WAAW,CAAC,CAAC;QAFD,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAAe;IAEzC,CAAC;IACD,mCAAQ,GAAR;QACE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;YACpB,IAAA,SAA8B,EAAtB,kBAAM,EAAE,gBAAK,CAAU;YAC/B,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;gBAChB,MAAM,CAAC,gBAAK,CAAC,QAAQ,WAAE,CAAC;YAC1B,CAAC;YAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtB,IAAI,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC;YACzB,CAAC;YACD,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IACH,uBAAC;AAAD,CAAC,AAjBD,CAAkC,uBAAU,GAiB3C","sourcesContent":["import { Operator } from '../Operator';\nimport { Subscriber } from '../Subscriber';\nimport { Observable } from '../Observable';\nimport { EmptyObservable } from '../observable/EmptyObservable';\nimport { TeardownLogic } from '../Subscription';\nimport { MonoTypeOperatorFunction } from '../interfaces';\n\n/**\n * Returns an Observable that repeats the stream of items emitted by the source Observable at most count times.\n *\n * <img src=\"./img/repeat.png\" width=\"100%\">\n *\n * @param {number} [count] The number of times the source Observable items are repeated, a count of 0 will yield\n * an empty Observable.\n * @return {Observable} An Observable that repeats the stream of items emitted by the source Observable at most\n * count times.\n * @method repeat\n * @owner Observable\n */\nexport function repeat<T>(count: number = -1): MonoTypeOperatorFunction<T> {\n return (source: Observable<T>) => {\n if (count === 0) {\n return new EmptyObservable<T>();\n } else if (count < 0) {\n return source.lift(new RepeatOperator(-1, source));\n } else {\n return source.lift(new RepeatOperator(count - 1, source));\n }\n };\n}\n\nclass RepeatOperator<T> implements Operator<T, T> {\n constructor(private count: number,\n private source: Observable<T>) {\n }\n call(subscriber: Subscriber<T>, source: any): TeardownLogic {\n return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source));\n }\n}\n\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\n * @extends {Ignored}\n */\nclass RepeatSubscriber<T> extends Subscriber<T> {\n constructor(destination: Subscriber<any>,\n private count: number,\n private source: Observable<T>) {\n super(destination);\n }\n complete() {\n if (!this.isStopped) {\n const { source, count } = this;\n if (count === 0) {\n return super.complete();\n } else if (count > -1) {\n this.count = count - 1;\n }\n source.subscribe(this._unsubscribeAndRecycle());\n }\n }\n}\n"]}
|