Repository navigation
util: support inspecting Map, Set, and Promise #1471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
613a63b
util: support inspecting Map and Set
monsanto 21e4e92
(rebase) add semicolons to test
monsanto 87e36a6
(rebase) check alignment of objects
monsanto 10d88e5
(rebase) these semicolons are going to be the end of me
monsanto 1185ff3
util: support inspecting Promises
monsanto c4d2cd0
(rebase) promise fixes
monsanto ba53e97
(rebase) fix showHidden on empty set/map
monsanto 79627ae
nits n stuff
monsanto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
(rebase) fix showHidden on empty set/map
we may mutate keys in the typecase, so don't check keys.length until no more mutations.
- Loading branch information
commit ba53e971475e13aab1cf746c3e00c341ae704105
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -285,11 +285,11 @@ function formatValue(ctx, value, recurseTimes) { | |
| } | ||
| } | ||
|
|
||
| var base = '', empty = keys.length === 0, braces, formatter; | ||
| var base = '', empty, braces, formatter; | ||
|
|
||
| if (Array.isArray(value)) { | ||
| braces = ['[', ']']; | ||
| empty = empty && value.length === 0; | ||
| empty = value.length === 0; | ||
| formatter = formatArray; | ||
| } else if (value instanceof Set) { | ||
| braces = ['Set {', '}']; | ||
|
|
@@ -298,14 +298,14 @@ function formatValue(ctx, value, recurseTimes) { | |
| // property isn't selected by Object.getOwnPropertyNames(). | ||
| if (ctx.showHidden) | ||
| keys.unshift('size'); | ||
| empty = empty && value.size === 0; | ||
| empty = value.size === 0; | ||
| formatter = formatSet; | ||
| } else if (value instanceof Map) { | ||
| braces = ['Map {', '}']; | ||
| // ditto | ||
| if (ctx.showHidden) | ||
| keys.unshift('size'); | ||
| empty = empty && value.size === 0; | ||
| empty = value.size === 0; | ||
| formatter = formatMap; | ||
| } else { | ||
| // Only create a mirror if the object superficially looks like a Promise | ||
|
|
@@ -316,10 +316,13 @@ function formatValue(ctx, value, recurseTimes) { | |
| formatter = formatPromise; | ||
| } else { | ||
| braces = ['{', '}']; | ||
| empty = true; // no other data than keys | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Femto-style nit: two spaces before the comment and please capitalize and punctuate it. Ditto for other comments. |
||
| formatter = formatObject; | ||
| } | ||
| } | ||
|
|
||
| empty = empty && keys.length === 0; | ||
|
|
||
| // Make functions say that they are functions | ||
| if (typeof value === 'function') { | ||
| var n = value.name ? ': ' + value.name : ''; | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preferably assign
empty = falseand use strict checks below (i.e.empty = empty === true && keys.length === 0andif (empty === true) {.)It's a minor thing but V8 emits marginally tighter code for strict boolean comparisons.