Skip to content

Instantly share code, notes, and snippets.

@jperocho
Created June 22, 2018 15:41
Show Gist options
  • Save jperocho/7528f4ca07554f2246dd54e5dedef065 to your computer and use it in GitHub Desktop.
Save jperocho/7528f4ca07554f2246dd54e5dedef065 to your computer and use it in GitHub Desktop.
Checks if two buffers are equal
const equalBuffer = (buffer1, buffer2) =>
buffer1.length !== buffer2.length
? false
: (() => {
for (let i = 0; i < buffer1.length; i++) {
if (buffer1.readUInt8(i) !== buffer2.readUInt8(i)) {
return false;
}
}
return true;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment