@@ -82,11 +82,39 @@ if (done) {
8282## Non-Goals
8383
8484* Growable shared array buffers are not part of this proposal.
85+ Adding BYOB support for ` SharedArrayBuffer ` in general can become its own separate proposal.
8586
8687## End-user Benefits
8788
88- * ...
89+ * Allows web developers to use resizable ` ArrayBuffer ` s in their stream processing,
90+ which can help to make their code more memory efficient.
91+ * Without resizable buffers, developers need to repeatedly allocate a new buffer
92+ and copy the old data into it, which can lead to memory fragmentation.
93+ * With a resizable buffer, developers can grow their existing buffer and make better use of
94+ the available memory (which could be very limited).
8995
9096## Alternatives
9197
92- * ...
98+ ### Non-resizable ` ArrayBuffer ` subarrays of a resizable ` ArrayBuffer `
99+
100+ Rather than changing the Streams standard to accept a resizable buffer,
101+ we could extend ` ArrayBuffer ` itself to allow creating a non-resizable ` ArrayBuffer ` view
102+ on part of its data, while still allowing the original resizable ` ArrayBuffer ` to be resized.
103+
104+ ``` javascript
105+ const buffer = new ArrayBuffer (1024 , { maxByteLength: 8192 });
106+ // Create a non-resizable `ArrayBuffer` that is backed by the same buffer,
107+ // but cannot be resized.
108+ // (This API does not currently exist.)
109+ const readBuffer = buffer .subarray (0 , 1024 );
110+ console .assert (readBuffer .resizable === false );
111+ const { value , done } = await reader .read (new Uint8Array (readBuffer, 0 , readBuffer .byteLength ));
112+ ```
113+
114+ However, this raises a lot more questions:
115+ * ` ArrayBuffer ` s generally "own" their backing data, but now multiple ` ArrayBuffer ` s
116+ may share (parts of) their backing data. This raises questions about transferability:
117+ * What happens to the subarray buffer if the parent buffer is transferred? Or vice versa?
118+ * Can the parent buffer still shrink to a smaller size, and what happens to its subarray buffers?
119+ * What makes an ` ArrayBuffer ` backed by a larger ` ArrayBuffer ` different from
120+ an ` ArrayBufferView ` backed by an ` ArrayBuffer ` ?
0 commit comments