error-if-index-how-many-or-array-are-not-valid

3.0.1 • Public • Published

errorIfIndex_howMany_orArray_areNotValid(
      index,
      howMany,
      array
): void

Triggers error if array has no .length, index is not a valid index of array (it is allowed
to be negative), or howMany is not an integer greater than zero.

Example

function getAdjacentAt(startingIndex, howMany, array) {
    // validate arguments:
    errorIfIndex_howMany_orArray_areNotValid(startingIndex, howMany, array);

    if (startingIndex + howMany === 0) return arraySlice(startingIndex, array.length, array);
    else return arraySlice(startingIndex, startingIndex + howMany, array);
}

Installation

npm i error-if-index-how-many-or-array-are-not-valid

Loading

import { errorIfIndex_howMany_orArray_areNotValid } 
	from 'error-if-index-how-many-or-array-are-not-valid';

License

MIT

Package Sidebar

Install

npm i error-if-index-how-many-or-array-are-not-valid

Weekly Downloads

0

Version

3.0.1

License

MIT

Unpacked Size

3.39 kB

Total Files

4

Last publish

Collaborators

  • writetome51