Skip to content
Subhajit Sahu edited this page May 17, 2020 · 27 revisions

Finds smallest and largest values. 🏃 [:vhs:] 📦 🌔 📒

Alternatives: compare, map.

iterable.range(x, [fc], [fm]);
// x:  an iterable
// fc: compare function (a, b)
// fm: map function (v, i, x)
// --> [min, max]
const iterable = require('extra-iterable');

var x = [1, 2, -3, -4];
iterable.range(x);
// [ -4, 2 ]

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

iterable.range(x, null, v => Math.abs(v));
// [ 1, -4 ]

references

Clone this wiki locally