structuredClone doesn't preserve `Set`
alexbezhan opened this issue · comments
Code:
const packr = new Packr({
structuredClone: true // is supposed to preserve Set
})
const obj = {
a: new Set([1])
}
const encoded = packr.encode(obj)
const decoded = packr.decode(encoded)
console.log(obj) // { a: Set(1) { 1 } }
console.log(decoded) // { a: [ 1 ] }. Wrong. Expected to be { a: Set(1) { 1 } }
Should be fixed in v1.8.2
I can confirm that it works now. Thank you 👍
It will be fair to note, that if you have old data persisted with structures
, you have to save it with a new version of msgpackr and only then the decoding will work for this data.