UNPKG

1.8 kBSource Map (JSON)View Raw
1{"version":3,"sources":["asynciterable/minby.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;;;;;;;GASG;AACH,MAAM,UAAU,KAAK,CACnB,MAA8B,EAC9B,OAAuC;IAEvC,MAAM,EACJ,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,qBAAqB,EAC9C,CAAC,UAAU,CAAC,EAAE,QAAQ,EACtB,CAAC,QAAQ,CAAC,EAAE,MAAM,GACnB,GAAG,OAAO,IAAI,EAAE,CAAC;IAClB,MAAM,WAAW,GAAG,KAAK,EAAE,GAAS,EAAE,QAAc,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC1F,OAAO,SAAS,CAAC,MAAM,EAAE,QAAS,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;AAC3D,CAAC","file":"minby.js","sourcesContent":["import { extremaBy } from './_extremaby';\nimport { ExtremaOptions } from './extremaoptions';\nimport { equalityComparerAsync } from '../util/comparer';\n\n/**\n * Returns the elements in an async-enumerable sequence with the minimum key value.\n *\n * @export\n * @template TSource The type of the elements in the source sequence.\n * @template TKey The type of the key computed for each element in the source sequence.\n * @param {AsyncIterable<TSource>} source An async-iterable sequence to get the minimum elements for.\n * @param {ExtremaOptions<TSource, TKey>} options The options which include an optional comparer and abort signal.\n * @returns {Promise<TSource[]>} A promise containing a list of zero or more elements that have a minimum key value.\n */\nexport function minBy<TSource, TKey>(\n source: AsyncIterable<TSource>,\n options?: ExtremaOptions<TSource, TKey>\n): Promise<TSource[]> {\n const {\n ['comparer']: comparer = equalityComparerAsync,\n ['selector']: selector,\n ['signal']: signal,\n } = options || {};\n const newComparer = async (key: TKey, minValue: TKey) => -(await comparer(key, minValue));\n return extremaBy(source, selector!, newComparer, signal);\n}\n"]}
\No newline at end of file