MCPcopy Create free account
hub / github.com/denoland/std / compareTypedArrays

Function compareTypedArrays

assert/equal.ts:76–82  ·  view source on GitHub ↗
(a: TypedArray, b: TypedArray)

Source from the content-addressed store, hash-verified

74type TypedArray = Pick<Uint8Array | BigUint64Array, "length" | number>;
75const TypedArray = Object.getPrototypeOf(Uint8Array);
76function compareTypedArrays(a: TypedArray, b: TypedArray) {
77 if (a.length !== b.length) return false;
78 for (let i = 0; i < b.length; i++) {
79 if (!sameValueZero(a[i], b[i])) return false;
80 }
81 return true;
82}
83
84/** Check both strict equality (`0 == -0`) and `Object.is` (`NaN == NaN`) */
85function sameValueZero(a: unknown, b: unknown) {

Callers 1

equalFunction · 0.85

Calls 1

sameValueZeroFunction · 0.70

Tested by

no test coverage detected