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 #5 circular structure error #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

emahuni
Copy link

@emahuni emahuni commented Sep 28, 2018

This works but was slow when working with large objs
It also fixes objects that have getters...
Check this out and see if it is an exceptable solution. Or we could disect the new module to make a much leaner solution out of it that is faster for this purpose.

used safe json stringify instead of native JSON.stringify to eliminate error when converting objects
with circular structure or getter functions. note, i tried this with sails object, it works but it's
a bit slow.
@emahuni
Copy link
Author

emahuni commented Sep 28, 2018

The travis fail is actually a test that's validating the bug as acceptable. I dont use ava maybe you could fix that upstream, pliz

@F1LT3R
Copy link
Owner

F1LT3R commented Sep 28, 2018

@emahuni how large do you mean? (Your JSON blob in KB stringified?)

I'd designed Chromafi to be used in small chunks of code that could be highlighted to show errors, or exported to SVG with ANSI-to-SVG when building example code blocks with crisp graphics for readme files.

What's your use case?

@F1LT3R
Copy link
Owner

F1LT3R commented Sep 28, 2018

Have you tried converting your object to a string and using Chromafi on that string with the {lang: 'javascript'} option?

It's possible that will give you faster results.

@emahuni
Copy link
Author

emahuni commented Sep 29, 2018

@emahuni how large do you mean? (Your JSON blob in KB stringified?)

I'd designed Chromafi to be used in small chunks of code that could be highlighted to show errors, or exported to SVG with ANSI-to-SVG when building example code blocks with crisp graphics for readme files.

What's your use case?

I have built a console trace logger Contrace that uses this for outputting objects, function etc for clean and intuitive logging. I then use this as the Sails logger of choice as it shows the source of logs etc.

I think with the new modifications I have done in this PR, it's ok for its intended usecase.

let me update Contrace with the latest code changes

@F1LT3R
Copy link
Owner

F1LT3R commented Oct 22, 2018

If you update the "circular json throws" test, I'm happy to merge your changes.

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