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 === registeredSymbol and to use the registeredSymbol-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 during revive().
- 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).
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:
Object.getOwnPropertySymbols()(and process also their values).key === registeredSymboland to use theregisteredSymbol-value to revive it again, e.g.:encapsulate()and reverse it duringrevive().