array-carousel
v1.0.0
Published
Infinite and negative array index support `array[-1]` `array[array.length]` using ES2015 Proxy
Downloads
13
Maintainers
Readme
array-carousel
Navigate through an array indefinitely. This allows you to use negative and out of range indexes on any given array.
Install
$ yarn add array-carousel # or npm i array-carousel
Usage
const carousel = require('array-carousel');
// Adds infinite (positive and negative) index support to any given array
const unicorn = carousel(['pony', 'cake', 'rainbow']);
console.log(unicorn[-1]) // 'rainbow'
console.log(unicorn[-9]) //'pony'
console.log(unicorn[4]) // 'cake'
unicorn[1] = null
console.log(unicorn[1]) // null
License
MIT