1 line
4.2 KiB
Plaintext
Executable File
1 line
4.2 KiB
Plaintext
Executable File
{"version":3,"file":"every.js","sourceRoot":"","sources":["../../src/operators/every.ts"],"names":[],"mappings":";;;;;;AAGA,2BAA2B,eAAe,CAAC,CAAA;AAG3C;;;;;;;;;;;;;GAaG;AACH,eAAyB,SAAsE,EACtE,OAAa;IACpC,MAAM,CAAC,UAAC,MAAqB,IAAK,OAAA,MAAM,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,EAA1D,CAA0D,CAAC;AAC/F,CAAC;AAHe,aAAK,QAGpB,CAAA;AAED;IACE,uBAAoB,SAAsE,EACtE,OAAa,EACb,MAAsB;QAFtB,cAAS,GAAT,SAAS,CAA6D;QACtE,YAAO,GAAP,OAAO,CAAM;QACb,WAAM,GAAN,MAAM,CAAgB;IAC1C,CAAC;IAED,4BAAI,GAAJ,UAAK,QAA6B,EAAE,MAAW;QAC7C,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACpG,CAAC;IACH,oBAAC;AAAD,CAAC,AATD,IASC;AAED;;;;GAIG;AACH;IAAiC,mCAAa;IAG5C,yBAAY,WAA8B,EACtB,SAAsE,EACtE,OAAY,EACZ,MAAsB;QACxC,kBAAM,WAAW,CAAC,CAAC;QAHD,cAAS,GAAT,SAAS,CAA6D;QACtE,YAAO,GAAP,OAAO,CAAK;QACZ,WAAM,GAAN,MAAM,CAAgB;QALlC,UAAK,GAAW,CAAC,CAAC;QAOxB,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,IAAI,CAAC;IACjC,CAAC;IAEO,wCAAc,GAAtB,UAAuB,eAAwB;QAC7C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACvC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;IAES,+BAAK,GAAf,UAAgB,KAAQ;QACtB,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/E,CAAE;QAAA,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACb,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC5B,MAAM,CAAC;QACT,CAAC;QAED,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YACZ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAES,mCAAS,GAAnB;QACE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IACH,sBAAC;AAAD,CAAC,AAjCD,CAAiC,uBAAU,GAiC1C","sourcesContent":["import { Operator } from '../Operator';\nimport { Observer } from '../Observer';\nimport { Observable } from '../Observable';\nimport { Subscriber } from '../Subscriber';\nimport { OperatorFunction } from '../interfaces';\n\n/**\n * Returns an Observable that emits whether or not every item of the source satisfies the condition specified.\n *\n * @example <caption>A simple example emitting true if all elements are less than 5, false otherwise</caption>\n * Observable.of(1, 2, 3, 4, 5, 6)\n * .every(x => x < 5)\n * .subscribe(x => console.log(x)); // -> false\n *\n * @param {function} predicate A function for determining if an item meets a specified condition.\n * @param {any} [thisArg] Optional object to use for `this` in the callback.\n * @return {Observable} An Observable of booleans that determines if all items of the source Observable meet the condition specified.\n * @method every\n * @owner Observable\n */\nexport function every<T>(predicate: (value: T, index: number, source: Observable<T>) => boolean,\n thisArg?: any): OperatorFunction<T, boolean> {\n return (source: Observable<T>) => source.lift(new EveryOperator(predicate, thisArg, source));\n}\n\nclass EveryOperator<T> implements Operator<T, boolean> {\n constructor(private predicate: (value: T, index: number, source: Observable<T>) => boolean,\n private thisArg?: any,\n private source?: Observable<T>) {\n }\n\n call(observer: Subscriber<boolean>, source: any): any {\n return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source));\n }\n}\n\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\n * @extends {Ignored}\n */\nclass EverySubscriber<T> extends Subscriber<T> {\n private index: number = 0;\n\n constructor(destination: Observer<boolean>,\n private predicate: (value: T, index: number, source: Observable<T>) => boolean,\n private thisArg: any,\n private source?: Observable<T>) {\n super(destination);\n this.thisArg = thisArg || this;\n }\n\n private notifyComplete(everyValueMatch: boolean): void {\n this.destination.next(everyValueMatch);\n this.destination.complete();\n }\n\n protected _next(value: T): void {\n let result = false;\n try {\n result = this.predicate.call(this.thisArg, value, this.index++, this.source);\n } catch (err) {\n this.destination.error(err);\n return;\n }\n\n if (!result) {\n this.notifyComplete(false);\n }\n }\n\n protected _complete(): void {\n this.notifyComplete(true);\n }\n}\n"]} |