Skip to content

JackGit/correct-index

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 

Repository files navigation

A lib to let you always get correct index of an array.

install

npm i correct-index --save

For example:

const correctIndex = require('correct-index')
const array = [0, 1, 2, 3]

correctIndex(0, array.length)   // return index as 0
correctIndex(-1, array.length)  // return index as 3
correctIndex(-4, array.length)  // return index as 0
correctIndex(5, array.length)   // return index as 1

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published