Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tyxla/recursive-min
Returns the smallest number from a multidimensional array or object.
https://github.com/tyxla/recursive-min
Last synced: about 1 month ago
JSON representation
Returns the smallest number from a multidimensional array or object.
- Host: GitHub
- URL: https://github.com/tyxla/recursive-min
- Owner: tyxla
- License: mit
- Created: 2016-01-02T15:39:07.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-02T16:56:13.000Z (about 9 years ago)
- Last Synced: 2023-12-24T01:02:59.583Z (about 1 year ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# recursive-min
Returns the smallest number from a multidimensional array or object.
```
npm install recursive-min
```[![Build Status](https://travis-ci.org/tyxla/recursive-min.svg)](https://travis-ci.org/tyxla/recursive-min)
## About
An easy to use solution for finding the smallest number from a multidimensional array or object.
Arrays and objects are traversed recursively, number values are compared, the rest are skipped.
Returns `false` on failure.
## Syntax
``` js
recursiveMin(objOrArray, min)
```#### objOrArray
Object or array to fetch the minimum number from.
#### min
Optional. Use it to specify a temporary minimum value.
## Usage
Call `recursiveMin()` by passing the array or object you wish to find the smallest number from. If you specify `min`, it will be the maximum possible result.
``` js
var input = [0, 12, [4, -5]];
var min = recursiveMin(input);console.log(min); // -5
```## License
MIT