Skip to content
Subhajit Sahu edited this page Feb 4, 2021 · 13 revisions

Finds smallest and largest entries. 📦 😺 🏃 📼 🌔 📜 📰 📘

Similar: min, max, range.


entries.range(x, [fc], [fm]);
// x:  entries
// fc: compare function (a, b)
// fm: map function (v, k, x)
// → [smallest, largest]
const entries = require("extra-entries");

var x = [["a", 1], ["b", 2], ["c", -3], ["d", -4]];
entries.range(x);
// [ [ "d", -4 ], [ "b", 2 ] ]

entries.range(x, (a, b) => Math.abs(a) - Math.abs(b));
// [ [ "a", 1 ], [ "d", -4 ] ]

entries.range(x, null, v => Math.abs(v));
// [ [ "a", 1 ], [ "d", -4 ] ]


References

Clone this wiki locally