Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/donmccurdy/circular-array
Simple circular array data structure, for storing a finite-length list of values
https://github.com/donmccurdy/circular-array
Last synced: 2 days ago
JSON representation
Simple circular array data structure, for storing a finite-length list of values
- Host: GitHub
- URL: https://github.com/donmccurdy/circular-array
- Owner: donmccurdy
- License: mit
- Archived: true
- Created: 2016-06-03T00:57:11.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-01-06T06:59:50.000Z (over 3 years ago)
- Last Synced: 2024-09-04T22:49:45.840Z (29 days ago)
- Language: JavaScript
- Homepage:
- Size: 332 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Circular Array
[![Latest NPM release](https://img.shields.io/npm/v/circular-array.svg)](https://www.npmjs.com/package/circular-array)
[![Minzipped size](https://badgen.net/bundlephobia/minzip/circular-array)](https://bundlephobia.com/result?p=circular-array)
[![License](https://img.shields.io/badge/license-MIT-007ec6.svg)](https://github.com/donmccurdy/circular-array/blob/master/LICENSE)
[![Build Status](https://travis-ci.com/donmccurdy/circular-array.svg?branch=master)](https://travis-ci.com/donmccurdy/circular-array)Simple circular array data structure, for storing a finite-length list of values and automatically
dropping values that no longer fit in the array. All operations are O(1).## Usage
```bash
npm install --save circular-array
``````javascript
// ES6
import { CircularArray } from 'circular-array';// CommonJS
const { CircularArray } = require('circular-array');const gizmos = new CircularArray(3);
// gizmo.array() returns:
gizmos.push(gizmo1); // [gizmo1]
gizmos.push(gizmo2); // [gizmo1, gizmo2]
gizmos.push(gizmo3); // [gizmo1, gizmo2, gizmo3]
gizmos.push(gizmo4); // [gizmo4, gizmo2, gizmo3]
```