@jswork/next-max-by
v1.0.1
Published
This method is like _.max except that it accepts iteratee which is invoked for each element in array to generate the criterion by which the value is ranked.
Downloads
60
Readme
next-max-by
This method is like _.max except that it accepts iteratee which is invoked for each element in array to generate the criterion by which the value is ranked.
installation
yarn add @jswork/next-max-by
usage
import '@jswork/next-max-by';
const arr = [
{ name: 'apple', value: 1 },
{ name: 'banana', value: 2 },
{ name: 'orange', value: 3 },
{ name: 'pear', value: 4 },
{ name: 'grape', value: 5 }
];
const result = nx.maxBy(arr, (x) => x.value);
console.log(result);
// { name: 'grape', value: 5 }
license
Code released under the MIT license.