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

better structuredClone support #68

Open
jimmywarting opened this issue Nov 28, 2022 · 4 comments
Open

better structuredClone support #68

jimmywarting opened this issue Nov 28, 2022 · 4 comments

Comments

@jimmywarting
Copy link

jimmywarting commented Nov 28, 2022

I have created this page to test out how good some packages are at mimicing structuredClone and also testing out how fast and efficent they are

https://jimmywarting.github.io/3th-party-structured-clone-wpt

Maybe you want imporove the score...?

@rvagg
Copy link
Owner

rvagg commented Nov 29, 2022

oh, very interesting! I think I can slightly improve the score with an encode option: { mapSorter: null } to override the default CBOR map sorting function; other than that the other items in the list are outside of the design goals of this library since its primary purpose is deterministic encoding forms and making novel CBOR tags pluggable (i.e. if you want Date, RegExp etc. then you bring your own tag plugin). Maybe something to work on because I export some basic tag plugins here; I just don't have the need for it.

Thanks for doing this though, perhaps I'll add a link on the README to it.

@jimmywarting
Copy link
Author

I'm just wondering how come that when running decode(encode(1n)) equals to 1 and not 1n?

@jimmywarting
Copy link
Author

Also if i would like to add a own Blob/File tag plugin then it would have to read the file in a async manner...
is there any possibility to encode/decode things in a async manner and await a result?

everything looks pretty sync to me in this package

@jimmywarting
Copy link
Author

jimmywarting commented Nov 29, 2022

i think that cbor also has references support? no?

i mean this example:

var input = Array(2).fill({})
var clone = decode(encode(input))
console.assert(clone => clone !== input)
console.assert(clone => clone[0] === clone[1])
console.assert(clone => clone[0] !== input[0])

it should pass?

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