1.0.0 • Published 7 years ago

typed-ring v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

typed-ring

This is a circular/ring buffer wrapped in a provided typed array.

const store = new TypedRing(Uint16Array, 500)

store.add([1,2,3,4,5,6,7])

const out = new Uint16Array(4)
store.fill(out)

// out => [4,5,6,7]

The API is pretty limited; just for recalling the last inserted items. The use case would be for capturing a stream of values and providing access to the most recent ones.

A store may be used with a shared buffer to allow updating/reading in different places.


TODO:

  • support SharedArrayBuffer (the main reason I was building this)
  • optimise copying of array