circularbuffer
v0.1.1
Published
A small circular/ring buffer implementation in TypeScript.
Downloads
1,094
Maintainers
Readme
circularbuffer
A small circular/ring buffer implementation in TypeScript.
Install
# using npm
npm install --save circularbuffer
# using yarn
yarn add circularbuffer
Usage
import CircularBuffer from 'circularbuffer';
const queue = new CircularBuffer<string|number>(5);
queue.enq('foo');
queue.enq('bar', 'baz');
queue.toArray(); // ['foo', 'bar', 'baz']
queue.size; // 3
queue.capacity; // 5
queue.replace(1, 2, 3, 4, 5, 6, 7);
queue.toArray(); // [3, 4, 5, 6, 7]
Development
# build
yarn run build
# test
yarn run test
License
MIT © Vince Coppola