(a, b)
| 54 | * @returns {boolean} true if the concatenations are byte-equal |
| 55 | */ |
| 56 | const bufferArraysEqual = (a, b) => { |
| 57 | let aIdx = 0; |
| 58 | let aOff = 0; |
| 59 | let bIdx = 0; |
| 60 | let bOff = 0; |
| 61 | while (aIdx < a.length && bIdx < b.length) { |
| 62 | const aBuf = a[aIdx]; |
| 63 | const bBuf = b[bIdx]; |
| 64 | const len = Math.min(aBuf.length - aOff, bBuf.length - bOff); |
| 65 | if (aBuf.compare(bBuf, bOff, bOff + len, aOff, aOff + len) !== 0) { |
| 66 | return false; |
| 67 | } |
| 68 | aOff += len; |
| 69 | bOff += len; |
| 70 | if (aOff === aBuf.length) { |
| 71 | aIdx++; |
| 72 | aOff = 0; |
| 73 | } |
| 74 | if (bOff === bBuf.length) { |
| 75 | bIdx++; |
| 76 | bOff = 0; |
| 77 | } |
| 78 | } |
| 79 | return aIdx === a.length && bIdx === b.length; |
| 80 | }; |
| 81 | |
| 82 | /** |
| 83 | * Map sources to their buffer chunks and deduplicate by total byte content, |
no test coverage detected