mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
25 lines
489 B
JavaScript
25 lines
489 B
JavaScript
|
|
class BufferUtils {
|
||
|
|
|
||
|
|
static areBuffersEqual(byteArray1, byteArray2) {
|
||
|
|
|
||
|
|
// ensure length is the same
|
||
|
|
if(byteArray1.length !== byteArray2.length){
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
// ensure each item is the same
|
||
|
|
for(let i = 0; i < byteArray1.length; i++){
|
||
|
|
if(byteArray1[i] !== byteArray2[i]){
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// arrays are the same
|
||
|
|
return true;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
export default BufferUtils;
|