Skip to content

Commit

Permalink
console: make groupIndent non-enumerable
Browse files Browse the repository at this point in the history
Hide the internal `groupIndent` key a bit by making it non-enumerable
and non-configurable.
  • Loading branch information
Trott committed Aug 24, 2017
1 parent 483dec7 commit 9df027b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ function Console(stdout, stderr, ignoreErrors = true) {
Object.defineProperty(this, '_stderrErrorHandler', prop);

this[kCounts] = new Map();

Object.defineProperty(this, kGroupIndent, { writable: true });
this[kGroupIndent] = '';

// bind the prototype functions to this Console instance
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-console-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,12 @@ function teardown() {
assert.strictEqual(stderr, expectedErr);
teardown();
}

// Check that the kGroupIndent symbol property is not enumerable
{
const keys = Reflect.ownKeys(console)
.filter((val) => console.propertyIsEnumerable(val))
.map((val) => val.toString());
assert(!keys.includes('Symbol(groupIndent)'),
'groupIndent should not be enumerable');
}

0 comments on commit 9df027b

Please sign in to comment.