-
Notifications
You must be signed in to change notification settings - Fork 0
min
Subhajit Sahu edited this page Jun 17, 2020
·
13 revisions
Finds smallest entry. 🏃 📼 📦 🌔 📒
entries.min(x, [fc], [fm]);
// x: entries
// 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);
// [ 'd', -4 ]
map.min(x, (a, b) => Math.abs(a) - Math.abs(b));
// [ 'a', 1 ]
map.min(x, null, v => Math.abs(v));
// [ 'a', 1 ]