11cb0ef41Sopenharmony_ci/* eslint-disable node-core/require-common-first, require-yield */ 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_ciconst { pipeline } = require('node:stream/promises'); 41cb0ef41Sopenharmony_ci{ 51cb0ef41Sopenharmony_ci // Ensure that async iterators can act as readable and writable streams 61cb0ef41Sopenharmony_ci async function* myCustomReadable() { 71cb0ef41Sopenharmony_ci yield 'Hello'; 81cb0ef41Sopenharmony_ci yield 'World'; 91cb0ef41Sopenharmony_ci } 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ci const messages = []; 121cb0ef41Sopenharmony_ci async function* myCustomWritable(stream) { 131cb0ef41Sopenharmony_ci for await (const chunk of stream) { 141cb0ef41Sopenharmony_ci messages.push(chunk); 151cb0ef41Sopenharmony_ci } 161cb0ef41Sopenharmony_ci } 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci (async () => { 191cb0ef41Sopenharmony_ci await pipeline( 201cb0ef41Sopenharmony_ci myCustomReadable, 211cb0ef41Sopenharmony_ci myCustomWritable, 221cb0ef41Sopenharmony_ci ); 231cb0ef41Sopenharmony_ci // Importing here to avoid initializing streams 241cb0ef41Sopenharmony_ci require('assert').deepStrictEqual(messages, ['Hello', 'World']); 251cb0ef41Sopenharmony_ci })() 261cb0ef41Sopenharmony_ci .then(require('../common').mustCall()); 271cb0ef41Sopenharmony_ci} 28