UNPKG

@extra-array/min

Version:
53 lines (38 loc) 1.35 kB
Finds smallest value. [:package:](https://www.npmjs.com/package/@extra-array/min) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/min) [:vhs:](https://asciinema.org/a/332100) [:moon:](https://www.npmjs.com/package/@extra-array/min.min) [:scroll:](https://unpkg.com/@extra-array/min/) [: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.min(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.min(x); // [ 3, -4 ] array.min(x, (a, b) => Math.abs(a) - Math.abs(b)); // [ 0, 1 ] array.min(x, null, v => Math.abs(v)); // [ 0, 1 ] ``` <br> <br> ## References - [Math.min: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) - [Array.min: sugarjs](https://sugarjs.com/docs/#/Array/min) [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