Comparing version 1.7.2 to 1.7.3
35
index.js
@@ -233,3 +233,3 @@ var assert = require('minimalistic-assert'); | ||
if (this.avail >= 2) { | ||
this.last.writeUInt16BE(v, this.offset, true); | ||
this.last.writeUInt16BE(v, this.offset); | ||
this.offset += 2; | ||
@@ -254,3 +254,3 @@ this.avail -= 2; | ||
if (this.avail >= 3) { | ||
this.last.writeUInt16BE(v >>> 8, this.offset, true); | ||
this.last.writeUInt16BE(v >>> 8, this.offset); | ||
this.last[this.offset + 2] = v & 0xff; | ||
@@ -263,3 +263,3 @@ this.offset += 3; | ||
} else if (this.avail >= 2) { | ||
this.last.writeUInt16BE(v >>> 8, this.offset, true); | ||
this.last.writeUInt16BE(v >>> 8, this.offset); | ||
this._next(); | ||
@@ -284,3 +284,3 @@ this.last[this.offset++] = v & 0xff; | ||
if (this.avail >= 4) { | ||
this.last.writeUInt32BE(v, this.offset, true); | ||
this.last.writeUInt32BE(v, this.offset); | ||
this.offset += 4; | ||
@@ -316,7 +316,24 @@ this.avail -= 4; | ||
WBuf.prototype.writeUInt32LE = function writeUInt32LE(num) { | ||
var r = ((num & 0xff) << 24) | | ||
(((num >>> 8) & 0xff) << 16) | | ||
(((num >>> 16) & 0xff) << 8) | | ||
(num >>> 24); | ||
this.writeUInt32BE(r); | ||
this._ensure(4); | ||
// Fast case - everything fits into the last buffer | ||
if (this.avail >= 4) { | ||
this.last.writeUInt32LE(num, this.offset); | ||
this.offset += 4; | ||
this.avail -= 4; | ||
this._move(4); | ||
// Three bytes here | ||
} else if (this.avail >= 3) { | ||
this.writeUInt24LE(num & 0xffffff); | ||
this._next(); | ||
this.last[this.offset++] = num >>> 24; | ||
this.avail--; | ||
this._move(1); | ||
// Slow case, who cares | ||
} else { | ||
this.writeUInt16LE(num & 0xffff); | ||
this.writeUInt16LE(num >>> 16); | ||
} | ||
}; | ||
@@ -323,0 +340,0 @@ |
{ | ||
"name": "wbuf", | ||
"version": "1.7.2", | ||
"version": "1.7.3", | ||
"description": "Write buffer", | ||
@@ -24,3 +24,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"mocha": "^1.21.4" | ||
"mocha": "^5.0.4" | ||
}, | ||
@@ -27,0 +27,0 @@ "dependencies": { |
20902
660
4