Open huypham50 opened 6 months ago
I've been hesitant to add any sort of official serialization/deserialization support to this library as it's possible to add data to the graph that is not serializable.
See this comment chain for more information https://github.com/jriecken/dependency-graph/commit/c9238dceba22188f1c74d025af37fea20744bc03#commitcomment-137327165
Ah, this wasn't an intentional change (although there's never really been a promise that the graph is JSON-serializable)
The only thing I worry about adding an official
toJSON()
/fromJSON(string)
is that it's possible for someone who is using this library to add a node that has data attached that is notJSON.stringify
able (e.g. as you've shown aMap
, or aFunction
, etc) and it's not clear what the output should be (fromJSON(graph.toJSON())
would not return the same thing)
Someone else had luck using this lib to serialize the graph - https://github.com/yahoo/serialize-javascript
Are there any suggestions on how to implement these two helpers?
Great library!