Package Exports
- error-if-index-not-valid
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (error-if-index-not-valid) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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 install error-if-index-not-valid
Loading
// if using TypeScript:
import { errorIfIndexNotValid } from 'error-if-index-not-valid';
// if using ES5 JavaScript:
var errorIfIndexNotValid = require('error-if-index-not-valid').errorIfIndexNotValid;