Permalink
Browse files

working implementation

  • Loading branch information...
1 parent 98c6019 commit ee448efb8e3550fd234e78213b34bff59ae04055 @substack committed May 11, 2012
Showing with 15 additions and 2 deletions.
  1. +1 −1 README.markdown
  2. +1 −1 example/eq.js
  3. +13 −0 index.js
View
@@ -14,7 +14,7 @@ console.dir(bufferEqual(
new Buffer([253,254,255])
));
console.dir(bufferEqual(
- new Buffer('abc')
+ new Buffer('abc'),
new Buffer('abcd')
));
console.dir(bufferEqual(
View
@@ -5,7 +5,7 @@ console.dir(bufferEqual(
new Buffer([253,254,255])
));
console.dir(bufferEqual(
- new Buffer('abc')
+ new Buffer('abc'),
new Buffer('abcd')
));
console.dir(bufferEqual(
View
@@ -0,0 +1,13 @@
+var Buffer = require('buffer').Buffer; // for use with browserify
+
+module.exports = function (a, b) {
+ if (!Buffer.isBuffer(a)) return undefined;
+ if (!Buffer.isBuffer(b)) return undefined;
+ if (a.length !== b.length) return false;
+
+ for (var i = 0; i < a.length; i++) {
+ if (a[i] !== b[i]) return false;
+ }
+
+ return true;
+};

0 comments on commit ee448ef

Please sign in to comment.