Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

circular-buffer

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

circular-buffer - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

10

package.json
{
"name": "circular-buffer",
"version": "1.0.2",
"description": "A NodeJS simple circular buffer implementation supporting indexing ",
"version": "1.0.3",
"description": "A NodeJS simple circular buffer implementation supporting indexing",
"main": "index.js",

@@ -10,4 +10,4 @@ "scripts": {

"devDependencies": {
"mocha": "^2.2.4",
"chai": "^2.2.0"
"chai": "^4.2.0",
"mocha": "^8.2.0"
},

@@ -22,3 +22,3 @@ "repository": {

],
"author": "Tom Smeding <hallo@tomsmeding.nl> (http://tomsmeding.com)",
"author": "Tom Smeding <tom.smeding@gmail.com> (https://tomsmeding.com)",
"license": "ISC",

@@ -25,0 +25,0 @@ "bugs": {

@@ -10,3 +10,3 @@ # NodeJS Circular Buffer

The implementation can function both as a queue (which it's most suited for), and as a (forgetful) stack. Queue functionality uses `enq()` and `deq()`; stack functionality uses `push()` and `pop()`. Values are enqueued at the front of the buffer and dequeued at the back of the buffer; pushing and popping is at the back of the buffer. Indexing is front-to-back: the last-enqueued item has lowest index, which is also the first-pushed item.
The implementation can function both as a forgetful queue (which it's most suited for), and as a (forgetful) stack. Queue functionality uses `enq()` and `deq()`; stack functionality uses `push()` and `pop()`. Values are enqueued at the front of the buffer and dequeued at the back of the buffer; pushing and popping is at the back of the buffer. Indexing is front-to-back: the last-enqueued item has lowest index, which is also the first-pushed item.

@@ -52,2 +52,8 @@ ## Usage

- Dequeue an item from the back of the buffer; returns that item. Throws `RangeError` if the buffer is empty on invocation.
- `push(value)`
- Push `value` at the back of the buffer
- `pop()` -> `value`
- Equivalent to `deq()`.
- `shift()` -> `value`
- Removes an item from the front of the buffer; returns that item. Throws `RangeError` if the buffer is empty on invocation.
- `get(idx)` -> `value`

@@ -54,0 +60,0 @@ - Get the value at index `idx`. `0` is the front of the buffer (last-enqueued item, or first-pushed item), `buf.size()-1` is the back of the buffer.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc