Comparing version 0.4.0 to 0.4.2
@@ -9,3 +9,3 @@ /*! | ||
* 构造方法 | ||
* @param bufferLength 缓存区长度,默认512 byte | ||
* @param bufferLength 缓存区长度,默认8k | ||
*/ | ||
@@ -16,3 +16,3 @@ var ExBuffer = function (bufferLength) { | ||
var _endian = 'B'; | ||
var _buffer = new Buffer(bufferLength || 512);//Buffer大于8kb 会使用slowBuffer,效率低 | ||
var _buffer = new Buffer(bufferLength || 8192); | ||
var _readOffset = 0; | ||
@@ -115,4 +115,4 @@ var _putOffset = 0; | ||
//buf.copy(targetBuffer, [targetStart], [sourceStart], [sourceEnd]) | ||
//当前缓冲区已经不能满足次数数据了 | ||
if(len + getLen() > _buffer.length){ | ||
//当前缓冲区已经不能满足次数数据了,这里我们保证尾部至少有一个位置永远空余,避免读写指针重叠 | ||
if(len + getLen() > _buffer.length - 1){ | ||
var ex = Math.ceil((len + getLen())/(1024));//每次扩展1kb | ||
@@ -119,0 +119,0 @@ var tmp = new Buffer(ex * 1024); |
@@ -9,3 +9,3 @@ { | ||
"main" : "ExBuffer.js", | ||
"version" : "0.4.0" | ||
"version" : "0.4.2" | ||
} |
18162