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

New principle: vend byte arrays as Uint8Arrays #480

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,19 @@ as the [Promise integration](https://github.com/WebAssembly/js-promise-integrati
is still under development as of today.
</div>

<h3 id="uint8array">Output an array of bytes with Uint8Array</h3>

If an API returns a byte array, make it a {{Uint8Array}}, not an {{ArrayBuffer}}.

`ArrayBuffer`s cannot be read from directly;
the developer would have to create a view such as a Uint8Array
to read data.
Providing a `Uint8Array` avoids that additional effort.

If the bytes in the buffer have a natural intepretation
as one of the other TypedArray types, provide that instead.
For example, if the bytes represent Float32 values, use a {{Float32Array}}.

<h2 id="event-design">Event Design</h2>

<h3 id="one-time-events">Use promises for one time events</h3>
Expand Down