Created
June 22, 2018 15:41
-
-
Save jperocho/7528f4ca07554f2246dd54e5dedef065 to your computer and use it in GitHub Desktop.
Checks if two buffers are equal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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