UNPKG

1.35 kBMarkdownView Raw
1Finds smallest and largest entries.
2[:package:](https://www.npmjs.com/package/@extra-lists/range)
3[:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-lists)
4[:running:](https://npm.runkit.com/@extra-lists/range)
5[:vhs:](https://asciinema.org/a/340784)
6[:moon:](https://www.npmjs.com/package/@extra-lists/range.min)
7[:scroll:](https://unpkg.com/@extra-lists/range/)
8[:newspaper:](https://nodef.github.io/extra-lists/)
9[:blue_book:](https://github.com/nodef/extra-lists/wiki/)
10
11> Similar: [min], [max], [range].
12
13> This is part of package [extra-lists].
14
15[extra-lists]: https://www.npmjs.com/package/extra-lists
16
17<br>
18
19```javascript
20lists.range(x, [fc], [fm]);
21// x: lists
22// fc: compare function (a, b)
23// fm: map function (v, k, x)
24// → [smallest, largest]
25```
26
27```javascript
28const lists = require('extra-lists');
29
30var x = [['a', 'b', 'c', 'd'], [1, 2, -3, -4]];
31lists.range(x);
32// [ [ 'd', -4 ], [ 'b', 2 ] ]
33
34lists.range(x, (a, b) => Math.abs(a) - Math.abs(b));
35// [ [ 'a', 1 ], [ 'd', -4 ] ]
36
37lists.range(x, null, v => Math.abs(v));
38// [ [ 'a', 1 ], [ 'd', -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-lists/wiki/min
50[max]: https://github.com/nodef/extra-lists/wiki/max
51[range]: https://github.com/nodef/extra-lists/wiki/range