megahash icon indicating copy to clipboard operation
megahash copied to clipboard

TypeError: Converting circular structure to JSON

Open tloriato opened this issue 5 years ago • 1 comments

https://github.com/jhuckaby/megahash/blob/cc0c1da3bfcd1fe97457a4ac78bdf746e3c39704/main.js#L28

When trying to store structures like AVL Trees and others that reference "themselves", the Stringify function throws this error. There's an option when calling the function to avoid this error, but I'm not sure how it impacts the rest of its usage in this module.

tloriato avatar Oct 28 '19 15:10 tloriato

Yeah, this is a known issue with JSON. There is actually a lot of things doesn't support, including circular references, functions, blessed objects (classes), and more. I'm afraid there isn't much I can do, unless I pull in a 3rd party library, which would slow down the JSON stringify/parse.

I will leave this issue open until I can figure out a solution, but I don't see how I can do it while keeping up the performance level.

jhuckaby avatar Oct 31 '19 02:10 jhuckaby