@reactivex/ix-es5-esm
Version:
The Interactive Extensions for JavaScript
19 lines (17 loc) • 971 B
JavaScript
import { extremaBy } from './_extremaby.js';
import { equalityComparer } from '../util/comparer.js';
/**
* Returns the elements in an terable sequence with the minimum key value.
*
* @template TSource The type of the elements in the source sequence.
* @template TKey The type of the key computed for each element in the source sequence.
* @param {Iterable<TSource>} source An async-iterable sequence to get the minimum elements for.
* @param {ExtremaOptions<TSource, TKey>} [options] The options which include an optional comparer.
* @returns {TSource[]} A list of zero or more elements that have a minimum key value.
*/
export function minBy(source, options) {
var _a = options || {}, _b = _a["comparer"], comparer = _b === void 0 ? equalityComparer : _b, selector = _a["selector"];
var newComparer = function (key, minValue) { return -comparer(key, minValue); };
return extremaBy(source, selector, newComparer);
}
//# sourceMappingURL=minby.js.map