Comparing version 0.0.4 to 0.0.5
@@ -61,8 +61,25 @@ function CBuffer() { | ||
}, | ||
// loop through each item in buffer | ||
forEach : function( callback, context ) { | ||
var i = 0; | ||
// check if context was passed | ||
if ( context ) { | ||
for (; i < this.size; i++ ) { | ||
callback.call( context, this.idx( i ), i, this ); | ||
} | ||
} else { | ||
for (; i < this.size; i++ ) { | ||
callback( this.idx( i ), i, this ); | ||
} | ||
} | ||
}, | ||
// return first item in buffer | ||
first : function() { | ||
return this.data[ this.start ]; | ||
}, | ||
// return last item in buffer | ||
last : function() { | ||
return this.data[ this.end ]; | ||
}, | ||
// return specific index in buffer | ||
idx : function( arg ) { | ||
@@ -69,0 +86,0 @@ return this.data[( this.start + arg ) % this.length ]; |
{ | ||
"name" : "CBuffer", | ||
"version" : "0.0.4", | ||
"version" : "0.0.5", | ||
"description" : "Circular Buffer JavaScript implementation", | ||
@@ -5,0 +5,0 @@ "homepage" : "http://github.com/trevnorris/cbuffer", |
3381
87