work.suroh.tk/node_modules/rxjs/operators/distinct.js.map

1 line
6.5 KiB
Plaintext

{"version":3,"file":"distinct.js","sourceRoot":"","sources":["../../src/operators/distinct.ts"],"names":[],"mappings":";;;;;;AAIA,gCAAgC,oBAAoB,CAAC,CAAA;AAErD,kCAAkC,2BAA2B,CAAC,CAAA;AAC9D,oBAA0B,aAAa,CAAC,CAAA;AAGxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,kBAA+B,WAA6B,EAC7B,OAAyB;IACtD,MAAM,CAAC,UAAC,MAAqB,IAAK,OAAA,MAAM,CAAC,IAAI,CAAC,IAAI,gBAAgB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,EAAvD,CAAuD,CAAC;AAC5F,CAAC;AAHe,gBAAQ,WAGvB,CAAA;AAED;IACE,0BAAoB,WAA4B,EAAU,OAAwB;QAA9D,gBAAW,GAAX,WAAW,CAAiB;QAAU,YAAO,GAAP,OAAO,CAAiB;IAClF,CAAC;IAED,+BAAI,GAAJ,UAAK,UAAyB,EAAE,MAAW;QACzC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9F,CAAC;IACH,uBAAC;AAAD,CAAC,AAPD,IAOC;AAED;;;;GAIG;AACH;IAA8C,sCAAqB;IAGjE,4BAAY,WAA0B,EAAU,WAA4B,EAAE,OAAwB;QACpG,kBAAM,WAAW,CAAC,CAAC;QAD2B,gBAAW,GAAX,WAAW,CAAiB;QAFpE,WAAM,GAAY,IAAI,SAAG,EAAK,CAAC;QAKrC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACZ,IAAI,CAAC,GAAG,CAAC,qCAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,uCAAU,GAAV,UAAW,UAAa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Observable';\nimport { Operator } from '../Operator';\nimport { Subscriber } from '../Subscriber';\nimport { TeardownLogic } from '../Subscription';\nimport { OuterSubscriber } from '../OuterSubscriber';\nimport { InnerSubscriber } from '../InnerSubscriber';\nimport { subscribeToResult } from '../util/subscribeToResult';\nimport { ISet, Set } from '../util/Set';\nimport { MonoTypeOperatorFunction } from '../interfaces';\n\n/**\n * Returns an Observable that emits all items emitted by the source Observable that are distinct by comparison from previous items.\n *\n * If a keySelector function is provided, then it will project each value from the source observable into a new value that it will\n * check for equality with previously projected values. If a keySelector function is not provided, it will use each value from the\n * source observable directly with an equality check against previous values.\n *\n * In JavaScript runtimes that support `Set`, this operator will use a `Set` to improve performance of the distinct value checking.\n *\n * In other runtimes, this operator will use a minimal implementation of `Set` that relies on an `Array` and `indexOf` under the\n * hood, so performance will degrade as more values are checked for distinction. Even in newer browsers, a long-running `distinct`\n * use might result in memory leaks. To help alleviate this in some scenarios, an optional `flushes` parameter is also provided so\n * that the internal `Set` can be \"flushed\", basically clearing it of values.\n *\n * @example <caption>A simple example with numbers</caption>\n * Observable.of(1, 1, 2, 2, 2, 1, 2, 3, 4, 3, 2, 1)\n * .distinct()\n * .subscribe(x => console.log(x)); // 1, 2, 3, 4\n *\n * @example <caption>An example using a keySelector function</caption>\n * interface Person {\n * age: number,\n * name: string\n * }\n *\n * Observable.of<Person>(\n * { age: 4, name: 'Foo'},\n * { age: 7, name: 'Bar'},\n * { age: 5, name: 'Foo'})\n * .distinct((p: Person) => p.name)\n * .subscribe(x => console.log(x));\n *\n * // displays:\n * // { age: 4, name: 'Foo' }\n * // { age: 7, name: 'Bar' }\n *\n * @see {@link distinctUntilChanged}\n * @see {@link distinctUntilKeyChanged}\n *\n * @param {function} [keySelector] Optional function to select which value you want to check as distinct.\n * @param {Observable} [flushes] Optional Observable for flushing the internal HashSet of the operator.\n * @return {Observable} An Observable that emits items from the source Observable with distinct values.\n * @method distinct\n * @owner Observable\n */\nexport function distinct<T, K>(keySelector?: (value: T) => K,\n flushes?: Observable<any>): MonoTypeOperatorFunction<T> {\n return (source: Observable<T>) => source.lift(new DistinctOperator(keySelector, flushes));\n}\n\nclass DistinctOperator<T, K> implements Operator<T, T> {\n constructor(private keySelector: (value: T) => K, private flushes: Observable<any>) {\n }\n\n call(subscriber: Subscriber<T>, source: any): TeardownLogic {\n return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes));\n }\n}\n\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\n * @extends {Ignored}\n */\nexport class DistinctSubscriber<T, K> extends OuterSubscriber<T, T> {\n private values: ISet<K> = new Set<K>();\n\n constructor(destination: Subscriber<T>, private keySelector: (value: T) => K, flushes: Observable<any>) {\n super(destination);\n\n if (flushes) {\n this.add(subscribeToResult(this, flushes));\n }\n }\n\n notifyNext(outerValue: T, innerValue: T,\n outerIndex: number, innerIndex: number,\n innerSub: InnerSubscriber<T, T>): void {\n this.values.clear();\n }\n\n notifyError(error: any, innerSub: InnerSubscriber<T, T>): void {\n this._error(error);\n }\n\n protected _next(value: T): void {\n if (this.keySelector) {\n this._useKeySelector(value);\n } else {\n this._finalizeNext(value, value);\n }\n }\n\n private _useKeySelector(value: T): void {\n let key: K;\n const { destination } = this;\n try {\n key = this.keySelector(value);\n } catch (err) {\n destination.error(err);\n return;\n }\n this._finalizeNext(key, value);\n }\n\n private _finalizeNext(key: K|T, value: T) {\n const { values } = this;\n if (!values.has(<K>key)) {\n values.add(<K>key);\n this.destination.next(value);\n }\n }\n\n}\n"]}