index.js 408 B

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