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,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AAC1D,CAAC","file":"scanright.js","sourcesContent":["import { IterableX } from './iterablex';\nimport { toArray } from './toarray';\n\nexport class ScanRightIterable<T, R> extends IterableX<R> {\n private _source: Iterable<T>;\n private _fn: (acc: R, x: T, index: number) => R;\n private _seed?: T | R;\n private _hasSeed: boolean;\n\n constructor(source: Iterable<T>, fn: (acc: R, x: T, index: number) => R, seed: R[]) {\n super();\n this._source = source;\n this._fn = fn;\n this._hasSeed = seed.length === 1;\n this._seed = seed[0];\n }\n\n *[Symbol.iterator]() {\n let hasValue = false,\n acc = this._seed;\n const source = toArray(this._source);\n for (let offset = source.length - 1; offset >= 0; offset--) {\n const item = source[offset];\n if (hasValue || (hasValue = this._hasSeed)) {\n acc = this._fn(<R>acc, item, offset);\n yield acc;\n } else {\n acc = item;\n hasValue = true;\n }\n }\n }\n}\n\nexport function scanRight<T, R = T>(\n source: Iterable<T>,\n accumulator: (previousValue: R, currentValue: T, currentIndex: number) => R,\n seed?: never[]\n): IterableX<R>;\nexport function scanRight<T, R = T>(\n source: Iterable<T>,\n accumulator: (previousValue: R, currentValue: T, currentIndex: number) => R,\n seed?: R\n): IterableX<R>;\nexport function scanRight<T, R = T>(\n source: Iterable<T>,\n accumulator: (previousValue: R, currentValue: T, currentIndex: number) => R,\n ...seed: R[]\n): IterableX<R> {\n return new ScanRightIterable(source, accumulator, seed);\n}\n"]}
\No newline at end of file