@reactivex/ix-esnext-esm
Version:
The Interactive Extensions for JavaScript
1 lines • 2.42 kB
Source Map (JSON)
{"version":3,"sources":["iterable/operators/distinct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGlE,MAAM,OAAO,gBAAgC,SAAQ,SAAkB;IAKrE,YACE,MAAyB,EACzB,WAAqC,EACrC,GAAkC;QAElC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QAChB,MAAM,GAAG,GAAG,EAAY,CAAC;QAEzB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;YAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACpC,IAAI,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC5C,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACd,MAAM,IAAI,CAAC;aACZ;SACF;IACH,CAAC;CACF;AAED,MAAM,UAAU,QAAQ,CACtB,cAAwC,QAAQ,EAChD,WAA0C,eAAe;IAEzD,OAAO,SAAS,wBAAwB,CAAC,MAAyB;QAChE,OAAO,IAAI,gBAAgB,CAAgB,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC5E,CAAC,CAAC;AACJ,CAAC","file":"distinct.js","sourcesContent":["import { IterableX } from '../iterablex';\nimport { identity } from '../../util/identity';\nimport { arrayIndexOf } from '../../util/arrayindexof';\nimport { comparer as defaultComparer } from '../../util/comparer';\nimport { MonoTypeOperatorFunction } from '../../interfaces';\n\nexport class DistinctIterable<TSource, TKey> extends IterableX<TSource> {\n private _source: Iterable<TSource>;\n private _keySelector: (value: TSource) => TKey;\n private _cmp: (x: TKey, y: TKey) => boolean;\n\n constructor(\n source: Iterable<TSource>,\n keySelector: (value: TSource) => TKey,\n cmp: (x: TKey, y: TKey) => boolean\n ) {\n super();\n this._source = source;\n this._keySelector = keySelector;\n this._cmp = cmp;\n }\n\n *[Symbol.iterator]() {\n const set = [] as TKey[];\n\n for (const item of this._source) {\n const key = this._keySelector(item);\n if (arrayIndexOf(set, key, this._cmp) === -1) {\n set.push(key);\n yield item;\n }\n }\n }\n}\n\nexport function distinct<TSource, TKey>(\n keySelector: (value: TSource) => TKey = identity,\n comparer: (x: TKey, y: TKey) => boolean = defaultComparer\n): MonoTypeOperatorFunction<TSource> {\n return function distinctOperatorFunction(source: Iterable<TSource>): IterableX<TSource> {\n return new DistinctIterable<TSource, TKey>(source, keySelector, comparer);\n };\n}\n"]}