Skip to content

This method is like _.min except that it accepts iteratee which is invoked for each element in array to generate the criterion by which the value is ranked.

License

Notifications You must be signed in to change notification settings

afeiship/next-min-by

Repository files navigation

next-min-by

This method is like _.min except that it accepts iteratee which is invoked for each element in array to generate the criterion by which the value is ranked.

version license size download

installation

yarn add @jswork/next-min-by

usage

import '@jswork/next-min-by';

// given an array of objects
const arr = [
  { name: 'apple', value: 10 },
  { name: 'banana', value: 20 },
  { name: 'orange', value: 15 },
  { name: 'pear', value: 25 }
];

// find the min value by `value` property
const result = nx.minBy(arr, 'value');
// result: { name: 'apple', value: 10 }  

// find the min value by function
const result2 = nx.minBy(arr, (item) =>item.value);
// result: { name: 'apple', value: 10 }  

license

Code released under the MIT license.

About

This method is like _.min except that it accepts iteratee which is invoked for each element in array to generate the criterion by which the value is ranked.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published