import { extremaBy } from './_extremaby' ; import { ExtremaOptions } from './extremaoptions' ; import { equalityComparer } from '../util/comparer' ; template TSource template TKey param { Iterable < TSource > } source param { ExtremaOptions < TSource , TKey > } options returns { TSource [ ] } export function minBy < TSource , TKey > ( source , options ? ) { const { [ 'comparer' ] : comparer = equalityComparer , [ 'selector' ] : selector } = options || { } ; const newComparer = ( key , minValue ) => - comparer ( key , minValue ) ; return extremaBy ( source , selector ! , newComparer ) ; }