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 aab0d20

Browse filesBrowse files
Nemanja Stojanovicjasnell
authored andcommitted
util: convert inspect.styles and inspect.colors to prototype-less objects
Use a prototype-less object for inspect.styles and inspect.colors to allow modification of Object.prototype in the REPL. Fixes: #11614 PR-URL: #11624 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
1 parent fd17e8b commit aab0d20
Copy full SHA for aab0d20

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+4
-4
lines changed
Open diff view settings
Collapse file

‎lib/util.js‎

Copy file name to clipboardExpand all lines: lib/util.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Object.defineProperty(inspect, 'defaultOptions', {
166166
});
167167

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

185185
// Don't use 'blue' not visible on cmd.exe
186-
inspect.styles = {
186+
inspect.styles = Object.assign(Object.create(null), {
187187
'special': 'cyan',
188188
'number': 'yellow',
189189
'boolean': 'yellow',
@@ -194,7 +194,7 @@ inspect.styles = {
194194
'date': 'magenta',
195195
// "name": intentionally not styling
196196
'regexp': 'red'
197-
};
197+
});
198198

199199
const customInspectSymbol = internalUtil.customInspectSymbol;
200200

0 commit comments

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