Skip to content

Commit dd64692

Browse files
authored
update readme with "Why Uint8Array" and "Why type: bytes" (#14)
These sections were missing when reverting back to Uint8Array
1 parent f7aa8b7 commit dd64692

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ Mutable can be problematic for several reasons:
141141

142142
See discussion in Issue https://github.com/styfle/proposal-import-bytes/issues/2 and https://github.com/styfle/proposal-import-bytes/issues/5
143143

144+
### Why Uint8Array?
145+
146+
Uint8Array is compatible with [Node.js Buffer](https://nodejs.org/api/buffer.html#buffer) which makes it widely compatible with existing JavaScript code.
147+
144148
### Why not ArrayBuffer?
145149

146150
ArrayBuffers cannot be read from directly; the developer must create a view, such as a Uint8Array, to read data. Providing a Uint8Array avoids that additional effort.
@@ -158,3 +162,7 @@ Blob is part of the W3C [File API](https://www.w3.org/TR/FileAPI/), not part of
158162
ReadableStream is part of the WHATWG [Streams](https://streams.spec.whatwg.org), not part of JavaScript, so it is not a viable solution to include in a TC39 Proposal. Furthermore, there is [no helper method](https://github.com/whatwg/streams/issues/1019) to turn a stream into a buffer so this won't solve the original motivation of writing isomorphic JavaScript.
159163

160164
See discussion in Issue https://github.com/styfle/proposal-import-bytes/issues/3
165+
166+
### Why `type: bytes`?
167+
168+
The `bytes()` method is familiar to those using [Response.bytes()](https://developer.mozilla.org/en-US/docs/Web/API/Response/bytes) or newer [Blob.bytes()](https://developer.mozilla.org/en-US/docs/Web/API/Blob/bytes) which both return Uint8Array.

0 commit comments

Comments
 (0)