(a, b, bitCount)
| 321 | // in every byte. If bitCount is included, only that leading number of bits |
| 322 | // have to match. |
| 323 | function equalBuffers(a, b, bitCount) { |
| 324 | var remainder; |
| 325 | |
| 326 | if (typeof bitCount === "undefined" && a.byteLength !== b.byteLength) { |
| 327 | return false; |
| 328 | } |
| 329 | |
| 330 | var aBytes = new Uint8Array(a); |
| 331 | var bBytes = new Uint8Array(b); |
| 332 | |
| 333 | var length = a.byteLength; |
| 334 | if (typeof bitCount !== "undefined") { |
| 335 | length = Math.floor(bitCount / 8); |
| 336 | } |
| 337 | |
| 338 | for (var i=0; i<length; i++) { |
| 339 | if (aBytes[i] !== bBytes[i]) { |
| 340 | return false; |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | if (typeof bitCount !== "undefined") { |
| 345 | remainder = bitCount % 8; |
| 346 | return aBytes[length] >> (8 - remainder) === bBytes[length] >> (8 - remainder); |
| 347 | } |
| 348 | |
| 349 | return true; |
| 350 | } |
| 351 | |
| 352 | // Returns a copy of the sourceBuffer it is sent. |
| 353 | function copyBuffer(sourceBuffer) { |
no outgoing calls
no test coverage detected