Skip to content

Question: Does js.NewArrayBuffer provide new functionality, or is it a convenience/helper func? #167

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

Closed
dmitshur opened this issue Jan 27, 2015 · 2 comments

Comments

@dmitshur
Copy link
Member

js.NewArrayBuffer was added in 59323cd.

If it's just a convenience/shortcut for what we could do before, what would the equivalent code be?

@neelance
Copy link
Member

See #165 . It was possible before with some js.InternalObject hack, but I did not like the solution and wanted to provide an officially supported one.

@neelance
Copy link
Member

@dominikh asked me to explain ArrayBufferView vs ArrayBuffer some more:

The ArrayBuffer is like a Go byte array of some fixed size. The ArrayBufferView is an abstract type, the concrete versions are Uint8Array, Int32Array, etc. Each ArrayBufferView is backed by an ArrayBuffer, just like a Go byte slice is backed by a byte array. Each ArrayBufferView has an offset and a length, also just like a Go slice. However, this offset and length and the read/write methods of an ArrayBufferView depend on the concrete type when finding the correct byte position in the underlying ArrayBuffer.

Hope this helps a bit.

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