UNPKG

@extra-array/max

Version:
53 lines (38 loc) 1.35 kB
Finds largest entry. [:package:](https://www.npmjs.com/package/@extra-array/max) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/max) [:vhs:](https://asciinema.org/a/332095) [:moon:](https://www.npmjs.com/package/@extra-array/max.min) [:scroll:](https://unpkg.com/@extra-array/max/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Similar: [min], [max], [range]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.max(x, [fc], [fm]); // x: an array // fc: compare function (a, b) // fm: map function (v, i, x) // → [index, value] ``` ```javascript 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 ] ``` <br> <br> ## References - [Math.max: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) - [Array.max: sugarjs](https://sugarjs.com/docs/#/Array/max) [max]: https://github.com/nodef/extra-array/wiki/max [min]: https://github.com/nodef/extra-array/wiki/min [range]: https://github.com/nodef/extra-array/wiki/range