fix display of big number objects to not add collapsable marker#27
Open
sseide wants to merge 1 commit into
Open
fix display of big number objects to not add collapsable marker#27sseide wants to merge 1 commit into
sseide wants to merge 1 commit into
Conversation
abodelot
requested changes
May 21, 2022
| // Add toggle button if item is collapsable | ||
| if (isCollapsable(json[i])) { | ||
| // Add toggle button if item is collapsable and not a big number | ||
| var ignoreItem = (options.bigNumbers && (typeof json[key].toExponential === 'function' || json[key].isLosslessNumber)); |
Owner
There was a problem hiding this comment.
Thanks for following up on your new feature!
I think we could avoid performing the big number check, and instead make a stricter type checking in isCollapsable :
function isCollapsable(arg) {
return (arg.constructor == Object && Object.keys(arg).length > 0) || (arg instanceof Array && arg.length > 0);
}So it would return true only for raw JS objects (and arrays).
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Using the big number libraries with the new support to display them directly i realized the current implementation shows the "collapsable" marker in front of the big numbers. But as this is useless for these numbers this patch removes them for this speacial case (bigNumbers support is activated and it is such a number)
This is the current state of display

And this is the new one with this patch and

options.bigNumbers=true