Skip to content

writetome51/error-if-index-not-valid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

errorIfIndexNotValid(
      index,
      arrayLength
): void

Triggers error if index cannot exist in arrayLength.
index is allowed to be negative.

Examples

errorIfIndexNotValid(1, 2); // No error.

errorIfIndexNotValid(2, 2);
// "Error:  The entered index is not valid.  Whether positive or negative,
// it exceeds the index range of the array."

errorIfIndexNotValid(-2, 2); // No error.

errorIfIndexNotValid(-3, 2);
// "Error:  The entered index is not valid.  Whether positive or negative,
// it exceeds the index range of the array."

errorIfIndexNotValid(1, 1);
// "Error:  The entered index is not valid.  Whether positive or negative,
// it exceeds the index range of the array."

Installation

npm i error-if-index-not-valid

Loading

import { errorIfIndexNotValid } from 'error-if-index-not-valid';

License

MIT

About

Function triggers error if a given index cannot exist in a given array length

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published