我们可以使用 Readable.from() 实用方法从异步生成器构造 Node.js 可读流:

    1. const { Readable } = require('stream');
    2. async function * generate() {
    3. yield 'a';
    4. yield 'b';
    5. yield 'c';
    6. }
    7. const readable = Readable.from(generate());
    8. readable.on('data', (chunk) => {
    9. console.log(chunk);
    10. });