-
Notifications
You must be signed in to change notification settings - Fork 1
max
Subhajit Sahu edited this page Jun 15, 2020
·
25 revisions
Finds largest entry. 🏃 📼 📦 🌔 📒
iterable.max(x, [fc], [fm]);
// x: an iterable
// fc: compare function (a, b)
// fm: map function (v, i, x)
// --> [index, value]
const iterable = require('extra-iterable');
var x = [1, 2, -3, -4];
iterable.max(x);
// [ 1, 2 ]
iterable.max(x, (a, b) => Math.abs(a) - Math.abs(b));
// [ 3, -4 ]
iterable.max(x, null, v => Math.abs(v));
// [ 3, -4 ]