Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tyxla/recursive-max
Returns the largest number from a multidimensional array or object.
https://github.com/tyxla/recursive-max
Last synced: about 1 month ago
JSON representation
Returns the largest number from a multidimensional array or object.
- Host: GitHub
- URL: https://github.com/tyxla/recursive-max
- Owner: tyxla
- License: mit
- Created: 2016-01-02T16:54:01.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-02T17:50:20.000Z (about 9 years ago)
- Last Synced: 2024-01-23T03:13:46.212Z (12 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# recursive-max
Returns the largest number from a multidimensional array or object.
```
npm install recursive-max
```[![Build Status](https://travis-ci.org/tyxla/recursive-max.svg)](https://travis-ci.org/tyxla/recursive-max)
## About
An easy to use solution for finding the largest 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
recursiveMax(objOrArray, max)
```#### objOrArray
Object or array to fetch the maximum number from.
#### max
Optional. Use it to specify a temporary maximum value.
## Usage
Call `recursiveMax()` by passing the array or object you wish to find the largest number from. If you specify `max`, it will be the maximum possible result.
``` js
var input = [0, 11, [4, 15]];
var max = recursiveMax(input);console.log(max); // 15
```## License
MIT