Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexmasterov/fixed-circular-buffer.js
A tiny (232 bytes) and fast Circular Buffer implementation
https://github.com/alexmasterov/fixed-circular-buffer.js
browser circular-buffer circular-queue cyclic-buffer fixed-queue javascript nodejs ring-buffer typescript
Last synced: about 4 hours ago
JSON representation
A tiny (232 bytes) and fast Circular Buffer implementation
- Host: GitHub
- URL: https://github.com/alexmasterov/fixed-circular-buffer.js
- Owner: AlexMasterov
- License: mit
- Created: 2018-10-05T21:39:23.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-05T15:31:25.000Z (almost 6 years ago)
- Last Synced: 2024-11-03T02:02:18.531Z (5 days ago)
- Topics: browser, circular-buffer, circular-queue, cyclic-buffer, fixed-queue, javascript, nodejs, ring-buffer, typescript
- Language: JavaScript
- Homepage:
- Size: 55.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fixed Circular Buffer
A tiny, fast and heap safe singly-linked list of fixed-size (2048) [circular buffers](https://en.wikipedia.org/wiki/Circular_buffer).
[![npm](https://img.shields.io/npm/v/fixed-circular-buffer.svg)](https://www.npmjs.com/package/fixed-circular-buffer)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Build Status](https://travis-ci.org/AlexMasterov/fixed-circular-buffer.js.svg)](https://travis-ci.org/AlexMasterov/fixed-circular-buffer.js)
[![Coverage Status](https://coveralls.io/repos/github/AlexMasterov/fixed-circular-buffer.js/badge.svg?branch=master)](https://coveralls.io/github/AlexMasterov/fixed-circular-buffer.js?branch=master)## Installation
```sh
# npm
npm install fixed-circular-buffer# yarn
yarn add fixed-circular-buffer
```## Usage
```javascript
const CircularBuffer = require('fixed-circular-buffer')const Q = new CircularBuffer()
Q.push('xyz')
Q.size // 1
Q.length // 2048Q.shift() // 'xyz'
Q.shift() // nulllet i = 2049 // data items
while (i > 0) Q.push(i -= 1)Q.size // 2049
Q.length // 4096
```## Tests
Run tests as follows:```
npm run test
```## License
Copyright © 2018–2019 Alex Masterov <[email protected]>Fixed Circular Buffer is licensed under MIT and can be used for any personal or commercial project.