Skip to content

Function triggers error if array is too short to return a requested number of adjacent items beginning at a particular index

License

Notifications You must be signed in to change notification settings

writetome51/error-if-array-too-short-to-meet-adjacent-items-request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

errorIfArrayTooShortToMeetAdjacentItemsRequest(
      startingIndex,
      numberRequested,
      arrayLength
): void

Triggers error if arrayLength is too short to have numberRequested adjacent
items beginning at startingIndex.
startingIndex can be negative or positive.

Example

let arr = [1,2,3,4,5,6];
errorIfArrayTooShortToMeetAdjacentItemsRequest(1, 6, arr.length);
// Error: "the array does not have enough items to fulfill your request"

Installation

npm install error-if-array-too-short-to-meet-adjacent-items-request

Loading

import { errorIfArrayTooShortToMeetAdjacentItemsRequest } 
    from 'error-if-array-too-short-to-meet-adjacent-items-request';

License

MIT

About

Function triggers error if array is too short to return a requested number of adjacent items beginning at a particular index

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published