Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 57043aa

Browse filesBrowse files
ferosscjihrig
authored andcommitted
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: #8001 PR-URL: #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>
1 parent 9f78c3f commit 57043aa
Copy full SHA for 57043aa

File tree

Expand file treeCollapse file tree

1 file changed

+6
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-2
lines changed
Open diff view settings
Collapse file

‎lib/assert.js‎

Copy file name to clipboardExpand all lines: lib/assert.js
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,12 @@ function _deepEqual(actual, expected, strict, memos) {
180180
pToString(actual) === pToString(expected) &&
181181
!(actual instanceof Float32Array ||
182182
actual instanceof Float64Array)) {
183-
return compare(Buffer.from(actual.buffer),
184-
Buffer.from(expected.buffer)) === 0;
183+
return compare(Buffer.from(actual.buffer,
184+
actual.byteOffset,
185+
actual.byteLength),
186+
Buffer.from(expected.buffer,
187+
expected.byteOffset,
188+
expected.byteLength)) === 0;
185189

186190
// 7.5 For all other Object pairs, including Array objects, equivalence is
187191
// determined by having the same number of owned properties (as verified

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.