From b363fd3e306213df8f6ba888997565aec13f9ac1 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sun, 11 Mar 2018 00:23:19 +0100 Subject: [PATCH] Remove buffers `noAssert` argument Support for the `noAssert` argument dropped in the upcoming Node.js v.10. This removes the argument to make sure everything works as it should. Refs: https://github.com/nodejs/node/pull/18395 --- i16.js | 4 ++-- i32.js | 4 ++-- i64.js | 16 ++++++++-------- message.js | 20 ++++++++++---------- skip.js | 6 +++--- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/i16.js b/i16.js index bb075f4..968d914 100644 --- a/i16.js +++ b/i16.js @@ -37,7 +37,7 @@ I16RW.prototype.min = -0x7fff - 1; I16RW.prototype.max = 0x7fff; I16RW.prototype.poolReadFrom = function poolReadFrom(result, buffer, offset) { - var value = buffer.readInt16BE(offset, true); + var value = buffer.readInt16BE(offset); return result.reset(null, offset + this.width, value); }; @@ -63,7 +63,7 @@ I16RW.prototype.poolWriteInto = function poolWriteInto(result, value, buffer, of })); } - buffer.writeInt16BE(coerced, offset, true); + buffer.writeInt16BE(coerced, offset); return result.reset(null, offset + this.width); }; diff --git a/i32.js b/i32.js index 8f2e22e..d8a8a35 100644 --- a/i32.js +++ b/i32.js @@ -37,7 +37,7 @@ I32RW.prototype.min = -0x7fffffff - 1; I32RW.prototype.max = 0x7fffffff; I32RW.prototype.poolReadFrom = function poolReadFrom(result, buffer, offset) { - var value = buffer.readInt32BE(offset, true); + var value = buffer.readInt32BE(offset); return result.reset(null, offset + this.width, value); }; @@ -63,7 +63,7 @@ I32RW.prototype.poolWriteInto = function poolWriteInto(result, value, buffer, of })); } - buffer.writeInt32BE(coerced, offset, true); + buffer.writeInt32BE(coerced, offset); return result.reset(null, offset + this.width); }; diff --git a/i64.js b/i64.js index 34217a3..03d6bea 100644 --- a/i64.js +++ b/i64.js @@ -46,8 +46,8 @@ I64RW.prototype.poolWriteInto = function poolWriteInto(destResult, value, buffer return this.writeBufferInt64Into(destResult, value, buffer, offset); } else if (typeof value === 'number') { var number = Long.fromNumber(value); - buffer.writeInt32BE(number.high, offset, true); - buffer.writeInt32BE(number.low, offset + 4, true); + buffer.writeInt32BE(number.high, offset); + buffer.writeInt32BE(number.low, offset + 4); return destResult.reset(null, offset + 8); } else if (Array.isArray(value)) { return this.writeArrayInt64Into(destResult, value, buffer, offset); @@ -76,8 +76,8 @@ function writeObjectInt64Into(destResult, value, buffer, offset) { '{hi[gh], lo[w]} with low bits, or other i64 representation'), null); } // Does not validate range of hi or lo value - buffer.writeInt32BE(value.high || value.hi, offset, true); - buffer.writeInt32BE(value.low || value.lo, offset + 4, true); + buffer.writeInt32BE(value.high || value.hi, offset); + buffer.writeInt32BE(value.low || value.lo, offset + 4); return destResult.reset(null, offset + 8); }; @@ -124,8 +124,8 @@ util.inherits(I64LongRW, I64RW); I64LongRW.prototype.poolReadFrom = function poolReadFrom(destResult, buffer, offset) { var value = Long.fromBits( - buffer.readInt32BE(offset + 4, 4, true), - buffer.readInt32BE(offset, 4, true) + buffer.readInt32BE(offset + 4, 4), + buffer.readInt32BE(offset, 4) ); return destResult.reset(null, offset + 8, value); }; @@ -138,8 +138,8 @@ util.inherits(I64DateRW, I64RW); I64DateRW.prototype.poolReadFrom = function poolReadFrom(destResult, buffer, offset) { var long = Long.fromBits( - buffer.readInt32BE(offset + 4, 4, true), - buffer.readInt32BE(offset + 0, 4, true) + buffer.readInt32BE(offset + 4, 4), + buffer.readInt32BE(offset + 0, 4) ); var ms = long.toNumber(); var value = new Date(ms); diff --git a/message.js b/message.js index 044867a..625fff5 100644 --- a/message.js +++ b/message.js @@ -194,7 +194,7 @@ MessageRW.prototype.poolLegacyWriteInto = function poolLegacyWriteInto(result, m // name~4 type:1 id:4 // name.length:4 - buffer.writeUInt32BE(message.name.length, offset, true); + buffer.writeUInt32BE(message.name.length, offset); offset += 4; // name:name.length @@ -212,14 +212,14 @@ MessageRW.prototype.poolLegacyWriteInto = function poolLegacyWriteInto(result, m offset += 1; // id:4 - buffer.writeUInt32BE(message.id, offset, true); + buffer.writeUInt32BE(message.id, offset); offset += 4; return result.reset(null, offset); }; MessageRW.prototype.poolReadFrom = function poolReadFrom(result, buffer, offset) { - var msb = buffer.readInt8(offset, true); + var msb = buffer.readInt8(offset); if (msb < 0) { result = this.poolStrictReadFrom(result, buffer, offset); } else { @@ -260,7 +260,7 @@ MessageRW.prototype.poolStrictReadFrom = function poolStrictReadFrom(result, buf // version:2 type:2 name~4 id:4 var message = new Message(); - message.version = buffer.readUInt16BE(offset, true) & ~0x8000; // mask out MSB + message.version = buffer.readUInt16BE(offset) & ~0x8000; // mask out MSB offset += 2; if (message.version !== 1) { @@ -270,7 +270,7 @@ MessageRW.prototype.poolStrictReadFrom = function poolStrictReadFrom(result, buf } // type:2 - var type = buffer.readUInt16BE(offset, true) & 0xFF; + var type = buffer.readUInt16BE(offset) & 0xFF; offset += 2; message.type = typeNames[type]; @@ -281,7 +281,7 @@ MessageRW.prototype.poolStrictReadFrom = function poolStrictReadFrom(result, buf } // name.length:4 - var length = buffer.readUInt32BE(offset, true); + var length = buffer.readUInt32BE(offset); offset += 4; // name:name.length @@ -289,7 +289,7 @@ MessageRW.prototype.poolStrictReadFrom = function poolStrictReadFrom(result, buf offset += length; // id:4 - message.id = buffer.readUInt32BE(offset, true); + message.id = buffer.readUInt32BE(offset); offset += 4; return result.reset(null, offset, message); @@ -300,7 +300,7 @@ MessageRW.prototype.poolLegacyReadFrom = function poolLegacyReadFrom(result, buf var message = new Message(); // name.length - var length = buffer.readUInt32BE(offset, true); + var length = buffer.readUInt32BE(offset); offset += 4; // name:name.length @@ -308,11 +308,11 @@ MessageRW.prototype.poolLegacyReadFrom = function poolLegacyReadFrom(result, buf offset += length; // type:2 - var type = buffer.readUInt8(offset, true); + var type = buffer.readUInt8(offset); offset += 1; // id:4 - message.id = buffer.readUInt32BE(offset, true); + message.id = buffer.readUInt32BE(offset); offset += 4; message.type = typeNames[type]; diff --git a/skip.js b/skip.js index 736e828..123a130 100644 --- a/skip.js +++ b/skip.js @@ -56,7 +56,7 @@ function skipField(destResult, buffer, offset) { }), offset); } - var typeid = buffer.readInt8(offset, true); + var typeid = buffer.readInt8(offset); offset += 1; return skipType(destResult, buffer, offset, typeid); @@ -109,7 +109,7 @@ function skipStruct(destResult, buffer, offset) { offset: offset }), offset); } - var typeid = buffer.readInt8(offset, true); + var typeid = buffer.readInt8(offset); offset += 1; if (typeid === TYPE.STOP) { @@ -149,7 +149,7 @@ function skipString(destResult, buffer, offset) { }), offset); } - var length = buffer.readInt32BE(offset, true); + var length = buffer.readInt32BE(offset); offset += 4; // istanbul ignore if