Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

buffer: remove duplicate assertion tests

Many assertion tests are duplicated in buffer.js. These few could be easily
removed and still have all tests pass.
  • Loading branch information...
commit 13c5db977190f926a213fc8ad7204e1febe36009 1 parent 5e4e87a
Trevor Norris trevnorris authored bnoordhuis committed
Showing with 0 additions and 33 deletions.
  1. +0 −33 lib/buffer.js
33 lib/buffer.js
View
@@ -1047,15 +1047,6 @@ Buffer.prototype.writeInt8 = function(value, offset, noAssert) {
var buffer = this;
if (!noAssert) {
- assert.ok(value !== undefined && value !== null,
- 'missing value');
-
- assert.ok(offset !== undefined && offset !== null,
- 'missing offset');
-
- assert.ok(offset < buffer.length,
- 'Trying to write beyond buffer length');
-
verifsint(value, 0x7f, -0x80);
}
@@ -1068,18 +1059,6 @@ Buffer.prototype.writeInt8 = function(value, offset, noAssert) {
function writeInt16(buffer, value, offset, isBigEndian, noAssert) {
if (!noAssert) {
- assert.ok(value !== undefined && value !== null,
- 'missing value');
-
- assert.ok(typeof (isBigEndian) === 'boolean',
- 'missing or invalid endian');
-
- assert.ok(offset !== undefined && offset !== null,
- 'missing offset');
-
- assert.ok(offset + 1 < buffer.length,
- 'Trying to write beyond buffer length');
-
verifsint(value, 0x7fff, -0x8000);
}
@@ -1100,18 +1079,6 @@ Buffer.prototype.writeInt16BE = function(value, offset, noAssert) {
function writeInt32(buffer, value, offset, isBigEndian, noAssert) {
if (!noAssert) {
- assert.ok(value !== undefined && value !== null,
- 'missing value');
-
- assert.ok(typeof (isBigEndian) === 'boolean',
- 'missing or invalid endian');
-
- assert.ok(offset !== undefined && offset !== null,
- 'missing offset');
-
- assert.ok(offset + 3 < buffer.length,
- 'Trying to write beyond buffer length');
-
verifsint(value, 0x7fffffff, -0x80000000);
}

2 comments on commit 13c5db9

Brian White

I could see how verifsint() can be used to verify that value is a number (and thus isn't null or undefined), but where are the other checks duplicated at?

Ben Noordhuis

@mscdex In the non-member writeUInt*() functions.

Please sign in to comment.
Something went wrong with that request. Please try again.