minEntry - nodef/extra-iterable GitHub Wiki

Find smallest entry.

Similar: min, minEntry, max, maxEntry, range, rangeEntries.

function minEntry(x, fc, fm)
// x:  an iterable
// fc: compare function (a, b)
// fm: map function (v, i, x)
const xiterable = require('extra-iterable');

var x = [1, 2, -3, -4];
xiterable.minEntry(x);
// → [3, -4]

xiterable.minEntry(x, (a, b) => Math.abs(a) - Math.abs(b));
// → [0, 1]

xiterable.minEntry(x, null, v => Math.abs(v));
// → [0, 1]

References