serialize-javascript
                                
                                 serialize-javascript copied to clipboard
                                
                                    serialize-javascript copied to clipboard
                            
                            
                            
                        Symbols
I'm not sure if you want to have symbols as part of this or not
{
  [Symbol('foo')]: Symbol('bar')
}
The current implementation uses JSON.stringify() with a replacer function, which doesn't support Symbol keys.
It could "work" for Symbol values, but I'm curious to know how you are thinking of using this feature…
We're planning to use something like serialize-javascript to deduplicate calls with the same arguments, by storing a serialized representation of the arguments and checking future calls against that.
I was trying to serialize code that was referencing library using symbols..
Here's the sample
const { Op } = require('sequelize');
const s = require('serialize-javascript')
const result = s( { [Op.eq]: 123 });
it produces {} because Op.eq is a Symbol :(
Symbols could be serialized in memory (by having a Map of symbols and their random stringified representation) but this will not work if you plan to save/restore the serialization on disk.
unfortunately, I'm saving/restoring on disk.
what's kind of interesting is that serialize({ foo: () => console.info(Op.eq) }); works, but I guess that's just how [Op.eq] behaves...