Skip to content
Subhajit Sahu edited this page Jun 18, 2020 · 14 revisions

Finds smallest entry. 🏃 📼 📦 🌔 📒

Similar: min, max, range.

lists.min(x, [fc], [fm]);
// x:  lists
// fc: compare function (a, b)
// fm: map function (v, k, x)
// --> [key, value]
const lists = require('extra-lists');

var x = [['a', 1], ['b', 2], ['c', -3], ['d', -4]];
lists.min(x);
// [ 'd', -4 ]

lists.min(x, (a, b) => Math.abs(a) - Math.abs(b));
// [ 'a', 1 ]

lists.min(x, null, v => Math.abs(v));
// [ 'a', 1 ]

references

Clone this wiki locally