Skip to content
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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sseide
Copy link
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
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