index.js 419 B

1234567891011121314
  1. var Buffer = require('buffer').Buffer; // for use with browserify
  2. module.exports = function (a, b) {
  3. if (!Buffer.isBuffer(a)) return undefined;
  4. if (!Buffer.isBuffer(b)) return undefined;
  5. if (typeof a.equals === 'function') return a.equals(b);
  6. if (a.length !== b.length) return false;
  7. for (var i = 0; i < a.length; i++) {
  8. if (a[i] !== b[i]) return false;
  9. }
  10. return true;
  11. };