-
Notifications
You must be signed in to change notification settings - Fork 333
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
Circular References are not handled #25
Comments
It's failing because it's trying to stringify the object back out to you - which is where the stack exception is kicking in. I guess the best I could do is to limit the depth of the stringify action - but that doesn't seem like a very elegant solution. Not quite sure there is a solution...! :-\ |
All you need to do to eliminate circular references is to traverse each node of the tree, keep a stack of the parent nodes, and for each node check to see if there is a copy (===) in the parent nodes. The tricky part that made me think it wasn't simple earlier was keeping a stack of the parent nodes. It doesn't sound so tricky now. @substack's js-traverse does this. You could use that to make a deep copy of an object with circular references scrubbed. It's in the README. |
Is a fix in the works for this, or should I fork and submit a patch? |
@mindeavor feel free to send a pull request - I'll certainly want to fix it - but I don't have the time right this mo. |
live and fixed (thank you!) |
The call stack maximum exceeds instead. Example:
The text was updated successfully, but these errors were encountered: