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 0.0.2 to 0.0.3

.npmignore

13

index.js

@@ -5,3 +5,4 @@ function CircularBuffer(capacity){

throw new TypeError("Invalid capacity");
var buffer=new Array(capacity),first=capacity-1,size=0;
var buffer=new Array(capacity),first=capacity,size=0;
this.size=function(){return size;};

@@ -31,5 +32,9 @@ this.capacity=function(){return capacity;};

var res=[],i;
for(i=start;i<=end;i++)res.push(buffer[(first+i)%capacity]);
return res;
if(first+start>=capacity){
//make sure first+start and first+end are in a normal range
start-=capacity; //becomes a negative number
end-=capacity;
}
if(first+end<capacity)return buffer.slice(first+start,first+end+1);
else return buffer.slice(first+start,capacity).concat(buffer.slice(0,first+end+1-capacity));
};

@@ -36,0 +41,0 @@ this.toarray=function(){

{
"name": "circular-buffer",
"version": "0.0.2",
"version": "0.0.3",
"description": "A NodeJS simple circular buffer implementation supporting indexing ",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha"
},
"devDependencies": {
"mocha": "^2.2.4",
"chai": "^2.2.0"
},
"repository": {

@@ -10,0 +14,0 @@ "type": "git",

@@ -47,1 +47,5 @@ # NodeJS Circular Buffer

- Equivalent to `buf.get(0,buf.size() - 1)`: exports all items in the buffer in order.
## Testing
To test the package simply run `npm update && npm test` in the package's root folder.
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