Skip to content
Subhajit Sahu edited this page Dec 5, 2022 · 16 revisions

Find smallest value.

Alternatives: min, minEntry.
Similar: min, max, range.


function min(x, fc, fm)
// x:  a map
// fc: compare function (a, b)
// fm: map function (v, k, x)
const map = require('extra-map');

var x = new Map([['a', 1], ['b', 2], ['c', -3], ['d', -4]]);
map.min(x);
// → -4

map.min(x, (a, b) => Math.abs(a) - Math.abs(b));
// → 1

map.min(x, null, v => Math.abs(v));
// → 1


References

Clone this wiki locally