MCPcopy Index your code
hub / github.com/nodejs/node / equalBuffers

Function equalBuffers

test/fixtures/wpt/WebCryptoAPI/util/helpers.js:323–350  ·  view source on GitHub ↗
(a, b, bitCount)

Source from the content-addressed store, hash-verified

321// in every byte. If bitCount is included, only that leading number of bits
322// have to match.
323function 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.
353function copyBuffer(sourceBuffer) {

Callers 15

define_bits_testsFunction · 0.85
define_key_testsFunction · 0.85
testAESOperationFunction · 0.85
testHMACOperationFunction · 0.85
define_testsFunction · 0.85
define_testsFunction · 0.85
define_testsFunction · 0.85
define_testsFunction · 0.85
define_testsFunction · 0.85
define_testsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected