JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4562264
  • Score
    100M100P100Q250242F

Cyclist is an efficient cyclic list implemention.

Package Exports

  • cyclist

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cyclist) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Cyclist

Cyclist is an efficient cyclic list implemention for Javascript. It is available through npm

npm install cyclist

Usage

var cyclist = require('cyclist');
var list = cyclist(4); // the size of the buffer should be a 2 magnitude
                       // this buffer can now hold 4 elements in total

list.put(42, 'hello 42'); // store something and index 42
list.put(43, 'hello 43'); // store something and index 43

console.log(list.get(42)); // prints hello 42
console.log(list.get(46)); // prints hello 42 again since 46 - 42 == list.size

You can use .fit(minElementsCount) to make sure the buffer can fit a certain amount of elements after it has been created.

list.fit(16); // list can now hold at least 16 elements

API

  • cyclist(minSize) creates a new buffer
  • cyclist#get(index) get an object stored in the buffer
  • cyclist#put(index,value) insert an object into the buffer
  • cyclist#del(index) delete an object from an index
  • cyclist#fit(minSize) resize the buffer if size is less than minSize
  • cyclist#size property containing current size of buffer

License

MIT