UNPKG

1.59 kBSource Map (JSON)View Raw
1{"version":3,"sources":["iterable/minby.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;;;;GASG;AACH,MAAM,UAAU,KAAK,CACnB,MAAyB,EACzB,OAAuC;IAEvC,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,gBAAgB,EAAE,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC5F,MAAM,WAAW,GAAG,CAAC,GAAS,EAAE,QAAc,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC5E,OAAO,SAAS,CAAC,MAAM,EAAE,QAAS,EAAE,WAAW,CAAC,CAAC;AACnD,CAAC","file":"minby.js","sourcesContent":["import { extremaBy } from './_extremaby';\nimport { ExtremaOptions } from './extremaoptions';\nimport { equalityComparer } from '../util/comparer';\n\n/**\n * Returns the elements in an terable 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 {Iterable<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.\n * @returns {TSource[]} A list of zero or more elements that have a minimum key value.\n */\nexport function minBy<TSource, TKey>(\n source: Iterable<TSource>,\n options?: ExtremaOptions<TSource, TKey>\n): TSource[] {\n const { ['comparer']: comparer = equalityComparer, ['selector']: selector } = options || {};\n const newComparer = (key: TKey, minValue: TKey) => -comparer(key, minValue);\n return extremaBy(source, selector!, newComparer);\n}\n"]}
\No newline at end of file