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AC;AAClB,CAAC","file":"min.js","sourcesContent":["import { equalityComparerAsync } from '../util/comparer';\nimport { identityAsync } from '../util/identity';\nimport { ExtremaOptions } from './extremaoptions';\nimport { wrapWithAbort } from './operators/withabort';\nimport { throwIfAborted } from '../aborterror';\n\n/**\n * * Returns the minimum element with the optional selector.\n *\n * @export\n * @template TSource The type of the elements in the source sequence.\n * @param {AsyncIterable<TSource>} source An async-iterable sequence to determine the minimum element of.\n * @param {ExtremaOptions<TSource, TKey>} [options] The options which include an optional comparer and abort signal.\n * @returns {Promise<TSource>} A promise containing the minimum element.\n */\nexport async function min<TSource, TResult = TSource>(\n source: AsyncIterable<TSource>,\n options?: ExtremaOptions<TSource, TResult>\n): Promise<TResult> {\n const {\n ['comparer']: comparer = equalityComparerAsync,\n ['signal']: signal,\n ['selector']: selector = identityAsync,\n } = options || {};\n\n throwIfAborted(signal);\n\n const it = wrapWithAbort(source, signal)[Symbol.asyncIterator]();\n let next = await it.next();\n\n if (next.done) {\n throw new Error('Sequence contains no elements');\n }\n\n let minValue = await selector(next.value);\n\n while (!(next = await it.next()).done) {\n const current = await selector(next.value);\n if ((await comparer(current, minValue)) < 0) {\n minValue = current;\n }\n }\n\n return minValue;\n}\n"]}
\No newline at end of file