Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

structuredClone doesn't preserve Set #95

Closed
alexbezhan opened this issue Dec 30, 2022 · 3 comments
Closed

structuredClone doesn't preserve Set #95

alexbezhan opened this issue Dec 30, 2022 · 3 comments

Comments

@alexbezhan
Copy link

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 } }
@alexbezhan alexbezhan changed the title structuredCloning doesn't preserve Set structuredClone doesn't preserve Set Dec 30, 2022
@kriszyp
Copy link
Owner

kriszyp commented Jan 24, 2023

Should be fixed in v1.8.2

@kriszyp kriszyp closed this as completed Mar 7, 2023
@alexbezhan
Copy link
Author

I can confirm that it works now. Thank you 👍

@alexbezhan
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants