Finds smallest and largest entries.
npm install @extra-array/rangeFinds smallest and largest entries.
:package:
:smiley_cat:
:running:
:vhs:
:moon:
:scroll:
:newspaper:
:blue_book:
> Similar: [min], [max], [range].
> This is part of package [extra-array].
[extra-array]: https://www.npmjs.com/package/extra-array
``javascript`
array.range(x, [fc], [fm]);
// x: an array
// fc: compare function (a, b)
// fm: map function (v, i, x)
// → [smallest, largest]
`javascript
const array = require("extra-array");
var x = [1, 2, -3, -4];
array.range(x);
// [ [ 3, -4 ], [ 1, 2 ] ]
array.range(x, (a, b) => Math.abs(a) - Math.abs(b));
// [ [ 0, 1 ], [ 3, -4 ] ]
array.range(x, null, v => Math.abs(v));
// [ [ 0, 1 ], [ 3, -4 ] ]
``
[min]: https://github.com/nodef/extra-array/wiki/min
[max]: https://github.com/nodef/extra-array/wiki/max
[range]: https://github.com/nodef/extra-array/wiki/range