Socket
Book a DemoInstallSign in
Socket

circular-at

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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.

latest
Source
npmnpm
Version
1.0.4
Version published
Weekly downloads
1.9K
-19.17%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

array

FAQs

Package last updated on 08 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts