UNPKG

3.13 kBSource Map (JSON)View Raw
1{"version":3,"sources":["asynciterable/sequenceequal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAwB/C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAwB,EACxB,KAAuB,EACvB,OAAgC;IAEhC,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,aAAa,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IACrF,cAAc,CAAC,MAAM,CAAC,CAAC;IACvB,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;IAClE,MAAM,GAAG,GAAG,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;IACjE,IAAI,KAAwB,CAAC;IAC7B,IAAI,KAAwB,CAAC;IAC7B,OAAO,CAAC,CAAC,KAAK,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QACvC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YACrF,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AACnC,CAAC","file":"sequenceequal.js","sourcesContent":["import { comparerAsync } from '../util/comparer';\nimport { wrapWithAbort } from './operators/withabort';\nimport { throwIfAborted } from '../aborterror';\n\n/**\n * The options for sequence equal operations including a comparer and abort signal\n *\n * @interface SequencEqualOptions\n * @template T The type of items to compare.\n */\nexport interface SequencEqualOptions<T> {\n /**\n * The comparer function which returns true if the items are equal, false otherwise.\n *\n * @memberof SequencEqualOptions\n */\n comparer?: (first: T, second: T) => boolean | Promise<boolean>;\n /**\n * An optional abort signal to cancel the operation at any time.\n *\n * @type {AbortSignal}\n * @memberof SequencEqualOptions\n */\n signal?: AbortSignal;\n}\n\n/**\n * Determines whether two sequences are equal by comparing the elements pairwise.\n *\n * @export\n * @template T The type of the elements in the source sequence.\n * @param {AsyncIterable<T>} source First async-iterable sequence to compare.\n * @param {AsyncIterable<T>} other Second async-iterable sequence to compare.\n * @param {SequencEqualOptions<T>} [options] The sequence equal options which include an optional comparer and optional abort signal.\n * @returns {Promise<boolean>} A promise which indicates whether both sequences are of equal length and their\n * corresponding elements are equal.\n */\nexport async function sequenceEqual<T>(\n source: AsyncIterable<T>,\n other: AsyncIterable<T>,\n options?: SequencEqualOptions<T>\n): Promise<boolean> {\n const { ['comparer']: comparer = comparerAsync, ['signal']: signal } = options || {};\n throwIfAborted(signal);\n const it1 = wrapWithAbort(source, signal)[Symbol.asyncIterator]();\n const it2 = wrapWithAbort(other, signal)[Symbol.asyncIterator]();\n let next1: IteratorResult<T>;\n let next2: IteratorResult<T>;\n while (!(next1 = await it1.next()).done) {\n if (!(!(next2 = await it2.next()).done && (await comparer(next1.value, next2.value)))) {\n return false;\n }\n }\n\n return !!(await it2.next()).done;\n}\n"]}
\No newline at end of file