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AAO,IAAI,EAAE,CAAC;QAChB,OAAO,IAAI,4BAA4B,CAAgB,MAAM,EAAE,WAAY,EAAE,QAAS,CAAC,CAAC;IAC1F,CAAC,CAAC;AACJ,CAAC","file":"distinctuntilchanged.js","sourcesContent":["import { IterableX } from '../iterablex';\nimport { identity } from '../../util/identity';\nimport { comparer as defaultComparer } from '../../util/comparer';\nimport { MonoTypeOperatorFunction } from '../../interfaces';\nimport { DistinctOptions } from './distinctoptions';\n\nexport class DistinctUntilChangedIterable<TSource, TKey = TSource> extends IterableX<TSource> {\n  private _source: Iterable<TSource>;\n  private _keySelector: (value: TSource) => TKey;\n  private _comparer: (x: TKey, y: TKey) => boolean;\n\n  constructor(\n    source: Iterable<TSource>,\n    keySelector: (value: TSource) => TKey,\n    comparer: (first: TKey, second: TKey) => boolean\n  ) {\n    super();\n    this._source = source;\n    this._keySelector = keySelector;\n    this._comparer = comparer;\n  }\n\n  *[Symbol.iterator]() {\n    let currentKey = <TKey>{};\n    let hasCurrentKey = false;\n    for (const item of this._source) {\n      const key = this._keySelector(item);\n      let comparerEquals = false;\n      if (hasCurrentKey) {\n        comparerEquals = this._comparer(currentKey, key);\n      }\n      if (!hasCurrentKey || !comparerEquals) {\n        hasCurrentKey = true;\n        currentKey = key;\n        yield item;\n      }\n    }\n  }\n}\n\n/**\n * Returns an async-iterable sequence that contains only distinct contiguous elements according to the optional keySelector and comparer.\n *\n * @export\n * @template TSource The type of the elements in the source sequence.\n * @template TKey The type of the discriminator key computed for each element in the source sequence.\n * @param {DistinctOptions<TSource, TKey = TSource>} [options] The optional options for adding a key selector and comparer.\n * @returns {MonoTypeOperatorFunction<TSource>} An operator that returns an async-iterable that contains only distinct contiguous items.\n */\nexport function distinctUntilChanged<TSource, TKey = TSource>(\n  options?: DistinctOptions<TSource, TKey>\n): MonoTypeOperatorFunction<TSource> {\n  return function distinctUntilChangedOperatorFunction(\n    source: Iterable<TSource>\n  ): IterableX<TSource> {\n    const { ['keySelector']: keySelector = identity, ['comparer']: comparer = defaultComparer } =\n      options || {};\n    return new DistinctUntilChangedIterable<TSource, TKey>(source, keySelector!, comparer!);\n  };\n}\n"]}