Skip to content

Commit

Permalink
Special deepEquals for buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Sep 8, 2010
1 parent 3c00ec4 commit 1be722a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ function _deepEqual(actual, expected) {
if (actual === expected) {
return true;

} else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) {
if (actual.length != expected.length) return false;

for (var i = 0; i < actual.length; i++) {
if (actual[i] !== expected[i]) return false;
}

return true;

// 7.2. If the expected value is a Date object, the actual value is
// equivalent if it is also a Date object that refers to the same time.
} else if (actual instanceof Date && expected instanceof Date) {
Expand Down

0 comments on commit 1be722a

Please sign in to comment.