1.0.7 • Published 6 years ago

ringway v1.0.7

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

Usage

Initialize a ring-buffer with 5 slots:

  import Ringway from 'ringway';
  
  const ringbuffer = new Ringway(5);

API

  • write - writes an element or an array of elements before overwriting and returns the number of elements written to the buffer
  • read - returns a single buffered element in FIFO order, and removes it from the buffer
  • getAll - get all buffer elements
  • clear - clears buffer
  • isEmpty - returns a boolean value indicating if the buffer is empty
  • isFull - returns a boolean value indicating if the buffer is full
  • maxSize - returns max size of the buffer

Config

  • debug - if the property has true value, messages with additional information will be written in console
  • schema - determines if data will be validated by provided schema with Joi API. Not valid elements won't be written in buffer

Example

  const ringbuffer = new Ringway(5, {
      debug: true,
      schema: function() {
        return this.Joi.number().integer();
      }
  });
  
  ringbuffer.write([1, 2, 3]);
  ringbuffer.read()
1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago