@extra-array/max

Finds largest entry. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Usage no npm install needed!

<script type="module">
  import extraArrayMax from 'https://cdn.skypack.dev/@extra-array/max';
</script>

README

Finds largest entry. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Similar: min, max, range.

This is part of package extra-array.


array.max(x, [fc], [fm]);
// x:  an array
// fc: compare function (a, b)
// fm: map function (v, i, x)
// → [index, value]
const array = require("extra-array");

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

array.max(x, (a, b) => Math.abs(a) - Math.abs(b));
// [ 3, -4 ]

array.max(x, null, v => Math.abs(v));
// [ 3, -4 ]


References