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

Find smallest value.

Similar: min, max, range.


function min(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.min(x);
// → -4

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

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


References

Clone this wiki locally