-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
Symbol-typed keys (and their values) are also something which gets lost in a JSON round-trip.
So it would be nice if typeson.js also supports key-rivival (next to value-revival).
This would mean:
- When iterating over object keys additionally iterate over symbols using
Object.getOwnPropertySymbols()(and process also their values). - Provide a possibility to register symbols to be able to test for a symbol using
key === registeredSymboland to use theregisteredSymbol-value to revive it again, e.g.:
const mySymbol = Symbol();
const otherSymbol = Symbol("symbol with description");
new Typeson().registerSymbolKeys({
MySymbol: mySymbol,
OtherSymbol: otherSymbol,
});- Change the symbol-keys to string-keys during
encapsulate()and reverse it duringrevive().- Here we need to avoid conflicts with equally named string-keys. This could be done by prefixing/postfixing them with a fixed value, or maybe by a random value (+ test loop).
Reactions are currently unavailable