Subtheme of barrio
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 lines
3.4 KiB

{"version":3,"file":"skipWhile.js","sourceRoot":"","sources":["../../src/operators/skipWhile.ts"],"names":[],"mappings":";;;;;;AAEA,2BAA2B,eAAe,CAAC,CAAA;AAI3C;;;;;;;;;;;GAWG;AACH,mBAA6B,SAA+C;IAC1E,MAAM,CAAC,UAAC,MAAqB,IAAK,OAAA,MAAM,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC,EAA7C,CAA6C,CAAC;AAClF,CAAC;AAFe,iBAAS,YAExB,CAAA;AAED;IACE,2BAAoB,SAA+C;QAA/C,cAAS,GAAT,SAAS,CAAsC;IACnE,CAAC;IAED,gCAAI,GAAJ,UAAK,UAAyB,EAAE,MAAW;QACzC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/E,CAAC;IACH,wBAAC;AAAD,CAAC,AAPD,IAOC;AAED;;;;GAIG;AACH;IAAqC,uCAAa;IAIhD,6BAAY,WAA0B,EAClB,SAA+C;QACjE,kBAAM,WAAW,CAAC,CAAC;QADD,cAAS,GAAT,SAAS,CAAsC;QAJ3D,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IAK1B,CAAC;IAES,mCAAK,GAAf,UAAgB,KAAQ;QACtB,IAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACrC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAClB,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QAED,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnB,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAEO,8CAAgB,GAAxB,UAAyB,KAAQ;QAC/B,IAAI,CAAC;YACH,IAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;YACnD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAClC,CAAE;QAAA,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACb,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IACH,0BAAC;AAAD,CAAC,AA5BD,CAAqC,uBAAU,GA4B9C","sourcesContent":["import { Observable } from '../Observable';\nimport { Operator } from '../Operator';\nimport { Subscriber } from '../Subscriber';\nimport { TeardownLogic } from '../Subscription';\nimport { MonoTypeOperatorFunction } from '../interfaces';\n\n/**\n * Returns an Observable that skips all items emitted by the source Observable as long as a specified condition holds\n * true, but emits all further source items as soon as the condition becomes false.\n *\n * <img src=\"./img/skipWhile.png\" width=\"100%\">\n *\n * @param {Function} predicate - A function to test each item emitted from the source Observable.\n * @return {Observable<T>} An Observable that begins emitting items emitted by the source Observable when the\n * specified predicate becomes false.\n * @method skipWhile\n * @owner Observable\n */\nexport function skipWhile<T>(predicate: (value: T, index: number) => boolean): MonoTypeOperatorFunction<T> {\n return (source: Observable<T>) => source.lift(new SkipWhileOperator(predicate));\n}\n\nclass SkipWhileOperator<T> implements Operator<T, T> {\n constructor(private predicate: (value: T, index: number) => boolean) {\n }\n\n call(subscriber: Subscriber<T>, source: any): TeardownLogic {\n return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));\n }\n}\n\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\n * @extends {Ignored}\n */\nclass SkipWhileSubscriber<T> extends Subscriber<T> {\n private skipping: boolean = true;\n private index: number = 0;\n\n constructor(destination: Subscriber<T>,\n private predicate: (value: T, index: number) => boolean) {\n super(destination);\n }\n\n protected _next(value: T): void {\n const destination = this.destination;\n if (this.skipping) {\n this.tryCallPredicate(value);\n }\n\n if (!this.skipping) {\n destination.next(value);\n }\n }\n\n private tryCallPredicate(value: T): void {\n try {\n const result = this.predicate(value, this.index++);\n this.skipping = Boolean(result);\n } catch (err) {\n this.destination.error(err);\n }\n }\n}\n"]}