mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
assert: fix deepEqual/deepStrictEqual on equivalent typed arrays
The typed array's underlying ArrayBuffer is used in `Buffer.from`. Let's respect it's .byteOffset or .byteLength (i.e. position within the parent ArrayBuffer). Fixes: https://github.com/nodejs/node/issues/8001 PR-URL: https://github.com/nodejs/node/pull/8002 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
bb3b4d7d49
commit
387ab62939
@ -180,8 +180,12 @@ function _deepEqual(actual, expected, strict, memos) {
|
||||
pToString(actual) === pToString(expected) &&
|
||||
!(actual instanceof Float32Array ||
|
||||
actual instanceof Float64Array)) {
|
||||
return compare(Buffer.from(actual.buffer),
|
||||
Buffer.from(expected.buffer)) === 0;
|
||||
return compare(Buffer.from(actual.buffer,
|
||||
actual.byteOffset,
|
||||
actual.byteLength),
|
||||
Buffer.from(expected.buffer,
|
||||
expected.byteOffset,
|
||||
expected.byteLength)) === 0;
|
||||
|
||||
// 7.5 For all other Object pairs, including Array objects, equivalence is
|
||||
// determined by having the same number of owned properties (as verified
|
||||
|
Loading…
Reference in New Issue
Block a user