Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 aTypedArray
. Closest thing isArrayBuffer.isView()
but this will also returns true forDataView
so I check it's not because freezing aDataView
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 useTypedArray
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 theinstanceof DataView
check.I'm more inclined to do the latter, you let me know.