UNPKG

1.32 kBMarkdownView Raw
1Finds smallest and largest entries.
2[:package:](https://www.npmjs.com/package/@extra-array/range)
3[:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array)
4[:running:](https://npm.runkit.com/@extra-array/range)
5[:vhs:](https://asciinema.org/a/332113)
6[:moon:](https://www.npmjs.com/package/@extra-array/range.min)
7[:scroll:](https://unpkg.com/@extra-array/range/)
8[:newspaper:](https://nodef.github.io/extra-array/)
9[:blue_book:](https://github.com/nodef/extra-array/wiki/)
10
11> Similar: [min], [max], [range].
12
13> This is part of package [extra-array].
14
15[extra-array]: https://www.npmjs.com/package/extra-array
16
17<br>
18
19```javascript
20array.range(x, [fc], [fm]);
21// x: an array
22// fc: compare function (a, b)
23// fm: map function (v, i, x)
24// → [smallest, largest]
25```
26
27```javascript
28const array = require("extra-array");
29
30var x = [1, 2, -3, -4];
31array.range(x);
32// [ [ 3, -4 ], [ 1, 2 ] ]
33
34array.range(x, (a, b) => Math.abs(a) - Math.abs(b));
35// [ [ 0, 1 ], [ 3, -4 ] ]
36
37array.range(x, null, v => Math.abs(v));
38// [ [ 0, 1 ], [ 3, -4 ] ]
39```
40
41<br>
42<br>
43
44
45## References
46
47- [range: MATLAB](https://www.mathworks.com/help/stats/range.html)
48
49[min]: https://github.com/nodef/extra-array/wiki/min
50[max]: https://github.com/nodef/extra-array/wiki/max
51[range]: https://github.com/nodef/extra-array/wiki/range