1/* eslint-disable node-core/require-common-first, require-yield */
2'use strict';
3const { pipeline } = require('node:stream/promises');
4{
5  // Ensure that async iterators can act as readable and writable streams
6  async function* myCustomReadable() {
7    yield 'Hello';
8    yield 'World';
9  }
10
11  const messages = [];
12  async function* myCustomWritable(stream) {
13    for await (const chunk of stream) {
14      messages.push(chunk);
15    }
16  }
17
18  (async () => {
19    await pipeline(
20      myCustomReadable,
21      myCustomWritable,
22    );
23    // Importing here to avoid initializing streams
24    require('assert').deepStrictEqual(messages, ['Hello', 'World']);
25  })()
26  .then(require('../common').mustCall());
27}
28