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

[suggestion] make use of structuredClone #8801

Closed
jimmywarting opened this issue Jun 22, 2023 · 2 comments
Closed

[suggestion] make use of structuredClone #8801

jimmywarting opened this issue Jun 22, 2023 · 2 comments

Comments

@jimmywarting
Copy link
Contributor

Describe the problem

not a actual problem...

Describe the proposed solution

I'm just looking tough the code and looking for anything i can help contribute with, i know nothing about how the internal core works or if it is even viable.
but i see code like this with a custom clone function:

export function clone(val) {

One suggestion is to use the available structuredClone whenever it exist or not. that way your own fn can be GC and will instead use the native one, that probably is also much faster? haven't bench tested it...

so my suggestion is to do something along the lines of:

export const clone = globalThis.structuredClone || function clone() { ...

Alternatives considered

the native structuredClone can clone more stuff, i'm not just sure yet what you are cloning but basically everything that can be stored in IndexedDB can be cloned deeply. it will include things such as date, regex, file, blobs, file handles and more.

Importance

nice to have

@Conduitry
Copy link
Member

structuredClone is a lot slower than the library that this was forked from - lukeed/klona#39 - so we don't want to use that even if it is available.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Jun 22, 2023
@jimmywarting
Copy link
Contributor Author

uh. did not know that it was a lot slower. okey then... that's fine

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