Skip to content

fix display of big number objects to not add collapsable marker#27

Open
sseide wants to merge 1 commit into
abodelot:masterfrom
sseide:update_big_numbers
Open

fix display of big number objects to not add collapsable marker#27
sseide wants to merge 1 commit into
abodelot:masterfrom
sseide:update_big_numbers

Conversation

@sseide
Copy link
Copy Markdown
Contributor

@sseide sseide commented May 19, 2022

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
big_numbers_old

And this is the new one with this patch and options.bigNumbers=true
big_numbers_new

// 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));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants