Skip to content

Fix #5 circular structure error#6

Open
emahuni wants to merge 4 commits into
F1LT3R:masterfrom
emahuni:master
Open

Fix #5 circular structure error#6
emahuni wants to merge 4 commits into
F1LT3R:masterfrom
emahuni:master

Conversation

@emahuni

@emahuni emahuni commented Sep 28, 2018

Copy link
Copy Markdown

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

emahuni commented Sep 28, 2018

Copy link
Copy Markdown
Author

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

F1LT3R commented Sep 28, 2018

Copy link
Copy Markdown
Owner

@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

F1LT3R commented Sep 28, 2018

Copy link
Copy Markdown
Owner

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

emahuni commented Sep 29, 2018

Copy link
Copy Markdown
Author

@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

F1LT3R commented Oct 22, 2018

Copy link
Copy Markdown
Owner

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