Skip to content

Conversation

@ghetolay
Copy link

So I came around that error : Cannot freeze array buffer views with elements

This error occurs when you try to freeze a TypedArray. I didn't find a nice way to check if our argument is a TypedArray. Closest thing is ArrayBuffer.isView() but this will also returns true for DataView so I check it's not because freezing a DataView doesn't raise the error (oddly) .

Now the second part of this pr is that I'm also currently returning, avoiding the loop through Object.getOwnPropertyNames(). This is because I assume when you use TypedArray you're dealing with binary data and you don't want to freeze each byte of it.

Maybe you don't want to do that assumption and let the user decide using an optional param.
Or we could extend that assumption to DataView as well and remove the instanceof DataView check.

I'm more inclined to do the latter, you let me know.

@vanslly
Copy link

vanslly commented Nov 8, 2018

This change was required for me where we use Uint8Array for row versions, for better or for worse.

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

Successfully merging this pull request may close these issues.

2 participants