ring-buffer-ts
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

Ring Buffer

Version MIT License

Aka "circular buffer" written in TypeScript

  • Well tested.
  • Documentation (included declaration types and doc-comments).
  • Clean and modern code.
  • Written in TypeScript (strict mode and strongly typed).
  • Easy API.
  • High performance when adding items.
  • No dependencies.
  • NodeJS, Browser.
  • Tiny size.

Missing feature? Note that you can export and import the buffer as an array and do whatever you want with the array. For example using slice. You can also consider creating an issue here and adding features via pull request. Note that the compatibility of protected members in the next minor or patch releases cannot be guaranteed and is not documented.

Install

npm i ring-buffer-ts

Usage

import { RingBuffer } from 'ring-buffer-ts';

const ringBuffer = new RingBuffer<number>(5);
ringBuffer.add(1);
ringBuffer.add(2, 3);
ringBuffer.add(4, 5, 6);

console.log(ringBuffer.toArray());
// Result: [2, 3, 4, 5, 6]

Documentation

Package Sidebar

Install

npm i ring-buffer-ts

Weekly Downloads

7,294

Version

1.2.0

License

MIT

Unpacked Size

20.8 kB

Total Files

7

Last publish

Collaborators

  • domske