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 4bf58ac

Browse filesBrowse files
BridgeARrvagg
authored andcommitted
util: update set iterator entries inspection
The inspection output for Set#entries() was wrong so far as it did not return an array as it should have. That was a bug in V8 that is now fixed and the code in Node.js has to be updated accordingly. PR-URL: #25941 Fixes: #24629 Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 206e4b0 commit 4bf58ac
Copy full SHA for 4bf58ac

File tree

Expand file treeCollapse file tree

3 files changed

+9
-13
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+9
-13
lines changed
Open diff view settings
Collapse file

‎lib/internal/util/inspect.js‎

Copy file name to clipboardExpand all lines: lib/internal/util/inspect.js
+5-10Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -594,11 +594,11 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
594594
} else if (isMapIterator(value)) {
595595
keys = getKeys(value, ctx.showHidden);
596596
braces = [`[${tag}] {`, '}'];
597-
formatter = formatMapIterator;
597+
formatter = formatIterator;
598598
} else if (isSetIterator(value)) {
599599
keys = getKeys(value, ctx.showHidden);
600600
braces = [`[${tag}] {`, '}'];
601-
formatter = formatSetIterator;
601+
formatter = formatIterator;
602602
} else {
603603
noIterator = true;
604604
}
@@ -730,10 +730,10 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
730730
}
731731
if (isMapIterator(value)) {
732732
braces = [`[${tag || 'Map Iterator'}] {`, '}'];
733-
formatter = formatMapIterator;
733+
formatter = formatIterator;
734734
} else if (isSetIterator(value)) {
735735
braces = [`[${tag || 'Set Iterator'}] {`, '}'];
736-
formatter = formatSetIterator;
736+
formatter = formatIterator;
737737
// Handle other regular objects again.
738738
} else if (keys.length === 0) {
739739
if (isExternal(value))
@@ -1090,12 +1090,7 @@ function formatWeakMap(ctx, value, recurseTimes) {
10901090
return formatMapIterInner(ctx, recurseTimes, entries, kWeak);
10911091
}
10921092

1093-
function formatSetIterator(ctx, value, recurseTimes) {
1094-
const entries = previewEntries(value);
1095-
return formatSetIterInner(ctx, recurseTimes, entries, kIterator);
1096-
}
1097-
1098-
function formatMapIterator(ctx, value, recurseTimes) {
1093+
function formatIterator(ctx, value, recurseTimes) {
10991094
const [entries, isKeyValue] = previewEntries(value, true);
11001095
if (isKeyValue) {
11011096
return formatMapIterInner(ctx, recurseTimes, entries, kMapEntries);
Collapse file

‎src/node_util.cc‎

Copy file name to clipboardExpand all lines: src/node_util.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static void PreviewEntries(const FunctionCallbackInfo<Value>& args) {
100100
Local<Array> entries;
101101
if (!args[0].As<Object>()->PreviewEntries(&is_key_value).ToLocal(&entries))
102102
return;
103-
// Fast path for WeakMap, WeakSet and Set iterators.
103+
// Fast path for WeakMap and WeakSet.
104104
if (args.Length() == 1)
105105
return args.GetReturnValue().Set(entries);
106106

Collapse file

‎test/parallel/test-util-inspect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-util-inspect.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,8 @@ if (typeof Symbol !== 'undefined') {
995995
const aSet = new Set([1, 3]);
996996
assert.strictEqual(util.inspect(aSet.keys()), '[Set Iterator] { 1, 3 }');
997997
assert.strictEqual(util.inspect(aSet.values()), '[Set Iterator] { 1, 3 }');
998-
assert.strictEqual(util.inspect(aSet.entries()), '[Set Iterator] { 1, 3 }');
998+
assert.strictEqual(util.inspect(aSet.entries()),
999+
'[Set Iterator] { [ 1, 1 ], [ 3, 3 ] }');
9991000
// Make sure the iterator doesn't get consumed.
10001001
const keys = aSet.keys();
10011002
assert.strictEqual(util.inspect(keys), '[Set Iterator] { 1, 3 }');
@@ -1609,7 +1610,7 @@ assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'");
16091610
[{ a: 5 }, '{ a: 5 }'],
16101611
[new Set([1, 2]), 'Set { 1, 2 }'],
16111612
[new Map([[1, 2]]), 'Map { 1 => 2 }'],
1612-
[new Set([1, 2]).entries(), '[Set Iterator] { 1, 2 }'],
1613+
[new Set([1, 2]).entries(), '[Set Iterator] { [ 1, 1 ], [ 2, 2 ] }'],
16131614
[new Map([[1, 2]]).keys(), '[Map Iterator] { 1 }'],
16141615
[new Date(2000), '1970-01-01T00:00:02.000Z'],
16151616
[new Uint8Array(2), 'Uint8Array [ 0, 0 ]'],

0 commit comments

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