!(b instanceof Buffer))
throw new TypeError('Arguments must be Buffers');
+ if (a === b)
+ return 0;
+
return internal.compare(a, b);
};
if (!(b instanceof Buffer))
throw new TypeError('Argument must be a Buffer');
+ if (this === b)
+ return true;
+
return internal.compare(this, b) === 0;
};
if (!(b instanceof Buffer))
throw new TypeError('Argument must be a Buffer');
+ if (this === b)
+ return 0;
+
return internal.compare(this, b);
};
assert.equal(c.compare(d), 1);
assert.equal(d.compare(b), 1);
assert.equal(b.compare(d), -1);
+assert.equal(b.compare(b), 0);
assert.equal(Buffer.compare(b, c), -1);
assert.equal(Buffer.compare(c, d), 1);
assert.equal(Buffer.compare(d, b), 1);
assert.equal(Buffer.compare(b, d), -1);
+assert.equal(Buffer.compare(c, c), 0);
+
assert.throws(function() {
var b = new Buffer(1);
assert.ok(b.equals(c));
assert.ok(!c.equals(d));
assert.ok(!d.equals(e));
+assert.ok(d.equals(d));
assert.throws(function() {
var b = new Buffer(1);