array-carousel

Infinite and negative array index support `array[-1]` `array[array.length]` using ES2015 Proxy

Usage no npm install needed!

<script type="module">
  import arrayCarousel from 'https://cdn.skypack.dev/array-carousel';
</script>

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