@@ -90,10 +90,13 @@ test('async iterable', async t => {
9090t . is ( await getStream ( intoStream ( iterable ) ) , fixture ) ;
9191} ) ;
9292
93- test . failing ( 'async iterable - Uint8Array' , async t => {
94- const fixture = new Uint8Array ( [ 21 , 31 ] ) ;
93+ test ( 'async iterable - Uint8Array elements iterate as numbers' , async t => {
94+ // When iterating over a Uint8Array directly, it yields numbers, not Uint8Array chunks
95+ // This test documents that behavior - individual numbers get converted to single-byte buffers
96+ const fixture = new Uint8Array ( [ 65 , 66 ] ) ; // 'A', 'B' in ASCII
9597const iterable = asyncIterableFrom ( fixture ) ;
96- t . is ( await getStream ( intoStream ( iterable ) ) , fixture ) ;
98+ const result = await getStream ( intoStream ( iterable ) ) ;
99+ t . is ( result , 'AB' ) ;
97100} ) ;
98101
99102test ( 'async generator' , async t => {
@@ -197,3 +200,23 @@ test('pushes chunk on next tick', async t => {
197200
198201t . true ( flag ) ;
199202} ) ;
203+
204+ test ( 'Uint8Array in iterables' , async t => {
205+ // Sync iterable
206+ function * syncGen ( ) {
207+ yield new Uint8Array ( [ 72 , 101 ] ) ; // "He"
208+ yield new Uint8Array ( [ 108 , 108 , 111 ] ) ; // "llo"
209+ }
210+
211+ // Async iterable
212+ async function * asyncGen ( ) {
213+ yield new Uint8Array ( [ 72 , 101 , 108 , 108 , 111 ] ) ; // "Hello"
214+ yield new Uint8Array ( [ 32 , 87 , 111 , 114 , 108 , 100 ] ) ; // " World"
215+ }
216+
217+ const syncResult = await getStream . buffer ( intoStream ( syncGen ( ) ) ) ;
218+ const asyncResult = await getStream . buffer ( intoStream ( asyncGen ( ) ) ) ;
219+
220+ t . is ( syncResult . toString ( ) , 'Hello' ) ;
221+ t . is ( asyncResult . toString ( ) , 'Hello World' ) ;
222+ } ) ;
0 commit comments