Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fixed-size-circular-array

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fixed-size-circular-array

Fixed size circular array datastructure

  • 0.7.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Circular Array

Fixed size circular array datastructure

Pipeline status Published on NPM

This data structure give an fixed size array, who reuse slots by overwriting existing items and allow to move first and last indexes

How to use

circularIndex

Function who returns the bounded index

./src/circularIndex.mjs

./browser/circularIndex.js

const boundedindex = circularIndex.circularIndex(index, length)

CircularArray

./src/CircularArray.mjs

./browser/CircularArray.js

const array = ['zero', 'one', 'two', 'three', 'four']
const circularArray = CircularArray.CircularArray.fromArray(array)

circularArray.firstIndex = 2

circularArray.getItem(3) // 'zero'

circularArray.selectPrevious() // first index is now set to 1 and last index to 0

circularArray.getItem(3) // 'four'
Availlable properties
  • firstIndex
  • firstItem
  • lastIndex
  • lastItem
Availlable methods
  • static fromArray(array)
  • indexToVirtualIndex(index)
  • getItem(index)
  • setItem(index, value)
  • selectPrevious()
  • selectNext()

Overwritten methods:

  • unshift(...itemList)
  • push(...itemList)
  • shift()
  • pop()

And all methods of Array.prototype with untested result

How to install

With Yarn

yarn add fixed-size-circular-array

or with NPM

npm install --save fixed-size-circular-array

License

MIT

Keywords

FAQs

Package last updated on 06 Jan 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc