Skip to content

Commit 9df027b

Browse files
committed
console: make groupIndent non-enumerable
Hide the internal `groupIndent` key a bit by making it non-enumerable and non-configurable.
1 parent 483dec7 commit 9df027b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/console.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ function Console(stdout, stderr, ignoreErrors = true) {
6060
Object.defineProperty(this, '_stderrErrorHandler', prop);
6161

6262
this[kCounts] = new Map();
63+
64+
Object.defineProperty(this, kGroupIndent, { writable: true });
6365
this[kGroupIndent] = '';
6466

6567
// bind the prototype functions to this Console instance

test/parallel/test-console-group.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,12 @@ function teardown() {
136136
assert.strictEqual(stderr, expectedErr);
137137
teardown();
138138
}
139+
140+
// Check that the kGroupIndent symbol property is not enumerable
141+
{
142+
const keys = Reflect.ownKeys(console)
143+
.filter((val) => console.propertyIsEnumerable(val))
144+
.map((val) => val.toString());
145+
assert(!keys.includes('Symbol(groupIndent)'),
146+
'groupIndent should not be enumerable');
147+
}

0 commit comments

Comments
 (0)