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

CBuffer

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

CBuffer - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

29

cbuffer.js

@@ -15,2 +15,4 @@ (function( global ) {

this.size = this.start = 0;
// set to callback fn if data is about to be overwritten
this.overflow = false;
// build CBuffer based on passed arguments

@@ -50,5 +52,12 @@ if ( arguments.length > 1 || typeof arguments[0] !== 'number' ) {

var i = 0;
// check if overflow is set, and if data is about to be overwritten
if ( this.overflow && this.size + arguments.length > this.length ) {
// call overflow function and send data that's about to be overwritten
for ( ; i < this.size + arguments.length - this.length; i++ ) {
this.overflow( this.data[( this.end + i + 1 ) % this.length ], this );
}
}
// push items to the end, wrapping and erasing existing items
// using arguments variable directly to reduce gc footprint
for ( ; i < arguments.length; i++ ) {
for ( i = 0; i < arguments.length; i++ ) {
this.data[( this.end + i + 1 ) % this.length ] = arguments[i];

@@ -105,3 +114,10 @@ }

var i = 0;
for ( ; i < arguments.length; i++ ) {
// check if overflow is set, and if data is about to be overwritten
if ( this.overflow && this.size + arguments.length > this.length ) {
// call overflow function and send data that's about to be overwritten
for ( ; i < this.size + arguments.length - this.length; i++ ) {
this.overflow( this.data[ this.end - ( i % this.length )], this );
}
}
for ( i = 0; i < arguments.length; i++ ) {
this.data[( this.length + this.start - ( i % this.length ) - 1 ) % this.length ] = arguments[i];

@@ -204,2 +220,11 @@ }

return this.data[( this.start + idx ) % this.length ] = arg;
},
// return clean array of values
toArray : function() {
var narr = new Array( this.size ),
i = 0;
for ( ; i < this.size; i++ ) {
narr[i] = this.data[( this.start + i ) % this.length ];
}
return narr;
}

@@ -206,0 +231,0 @@ };

2

package.json
{
"name" : "CBuffer",
"version" : "0.0.6",
"version" : "0.0.7",
"description" : "Circular Buffer JavaScript implementation",

@@ -5,0 +5,0 @@ "homepage" : "http://github.com/trevnorris/cbuffer",

@@ -45,1 +45,3 @@ ## JavaScript [Circular Buffer](http://en.wikipedia.org/wiki/Circular_buffer) Utility

* set()
* toArray() - Return clean ordered array of buffer
* overflow - Set to function and will be called when data is about to be overwritten
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