max - nodef/extra-set GitHub Wiki

Find largest value.

Similar: min, max, range.

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

var x = new Set([1, 2, -3, -4]);
set.max(x);
// → 2

set.max(x, (a, b) => Math.abs(a) - Math.abs(b));
// → -4

set.max(x, null, v => Math.abs(v));
// → -4

References