Comparing version 0.1.2 to 0.1.3
@@ -7,2 +7,3 @@ (function(global) { | ||
if (!(this instanceof CBuffer)) { | ||
// multiple conditions need to be checked to properly emulate Array | ||
if (arguments.length > 1 || typeof arguments[0] !== 'number') { | ||
@@ -14,2 +15,4 @@ return CBuffer.apply(new CBuffer(), arguments); | ||
} | ||
// if no arguments, then nothing needs to be set | ||
if (arguments.length === 0) return this; | ||
// this is the same in either scenario | ||
@@ -19,3 +22,3 @@ this.size = this.start = 0; | ||
this.overflow = false; | ||
// build CBuffer based on passed arguments | ||
// emulate Array based on passed arguments | ||
if (arguments.length > 1 || typeof arguments[0] !== 'number') { | ||
@@ -29,2 +32,3 @@ this.data = new Array(arguments.length); | ||
} | ||
// need to `return this` so `return CBuffer.apply` works | ||
return this; | ||
@@ -105,3 +109,3 @@ } | ||
var item; | ||
// check if there are any items in CBuff | ||
// check if there are any items in CBuffer | ||
if (this.size === 0) return; | ||
@@ -108,0 +112,0 @@ // store first item for return |
{ | ||
"name" : "CBuffer", | ||
"version" : "0.1.2", | ||
"version" : "0.1.3", | ||
"description" : "Circular Buffer JavaScript implementation", | ||
@@ -5,0 +5,0 @@ "homepage" : "https://github.com/trevnorris/cbuffer", |
19311
546