JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3918
  • Score
    100M100P100Q121584F
  • License MIT

Access array items at any positive or negative index. If the index is out of bounds, it will be wrapped around the length of the array.

Package Exports

  • circular-at

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (circular-at) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

circular-at

Access array items at any positive or negative index. If the index is out of bounds, it will be wrapped around the length of the array.

For example:

import at from 'circular-at'

const array = ['a', 'b', 'c']

at(array, 0) === 'a'
at(array, 1) === 'b'
at(array, 2) === 'c'
at(array, 3) === 'a'
at(array, 4) === 'b'
at(array, 5) === 'c'

// ... and so on

This goes for negative indices as well:

at(array, -1) === 'c'
at(array, -2) === 'b'
at(array, -3) === 'a'
at(array, -4) === 'c'
at(array, -5) === 'b'

// ... and so on

If the given value is not an array, it behaves like value[index]

Install

npm install circular-at

License

MIT