-
Notifications
You must be signed in to change notification settings - Fork 0
minEntry
Subhajit Sahu edited this page Dec 22, 2022
·
1 revision
Find smallest entry.
function minEntry(x, fc, fm)
// x: entries
// fc: compare function (a, b)
// fm: map function (v, k, x)
const entries = require('extra-entries');
var x = [["a", 1], ["b", 2], ["c", -3], ["d", -4]];
entries.minEntry(x);
// → [ "d", -4 ]
entries.minEntry(x, (a, b) => Math.abs(a) - Math.abs(b));
// → [ "a", 1 ]
entries.minEntry(x, null, v => Math.abs(v));
// → [ "a", 1 ]