https://github.com/writetome51/index-is-valid
Function returns true or false based on whether or not a certain index can exist in a certain array length
https://github.com/writetome51/index-is-valid
array index javascript typescript valid validation
Last synced: 12 months ago
JSON representation
Function returns true or false based on whether or not a certain index can exist in a certain array length
- Host: GitHub
- URL: https://github.com/writetome51/index-is-valid
- Owner: writetome51
- License: mit
- Created: 2019-03-29T06:11:19.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-19T07:23:03.000Z (almost 5 years ago)
- Last Synced: 2024-04-25T11:02:47.356Z (almost 2 years ago)
- Topics: array, index, javascript, typescript, valid, validation
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# indexIsValid(index, arrayLength): boolean
Returns true or false based on whether or not `index` can exist in `arrayLength`.
`index` can be negative or positive.
## Examples
```js
indexIsValid(0, 0); // --> false
indexIsValid(1, 1); // --> false
indexIsValid(-1, 1); // --> true
indexIsValid(1, 2); // --> true
indexIsValid(-2, 2); // --> true
indexIsValid(-3, 2); // --> false
```
## Installation
`npm i @writetome51/index-is-valid`
## Loading
```js
import { indexIsValid } from '@writetome51/index-is-valid';
```
## License
[MIT](https://choosealicense.com/licenses/mit/)