Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
util: convert inspect.styles and inspect.colors to prototype-less obj…
…ects

Use a prototype-less object for inspect.styles and inspect.colors to allow
modification of Object.prototype in the REPL.

Fixes: #11614
  • Loading branch information
Nemanja Stojanovic authored and Nemanja Stojanovic committed Mar 1, 2017
commit f3e63ea32c795474a9c92d38b06188d54fd92be3
8 changes: 4 additions & 4 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Object.defineProperty(inspect, 'defaultOptions', {
});

// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
inspect.colors = {
inspect.colors = Object.assign(Object.create(null), {
'bold': [1, 22],
'italic': [3, 23],
'underline': [4, 24],
Expand All @@ -180,10 +180,10 @@ inspect.colors = {
'magenta': [35, 39],
'red': [31, 39],
'yellow': [33, 39]
};
});

// Don't use 'blue' not visible on cmd.exe
inspect.styles = {
inspect.styles = Object.assign(Object.create(null), {
'special': 'cyan',
'number': 'yellow',
'boolean': 'yellow',
Expand All @@ -194,7 +194,7 @@ inspect.styles = {
'date': 'magenta',
// "name": intentionally not styling
'regexp': 'red'
};
});

const customInspectSymbol = internalUtil.customInspectSymbol;

Expand Down