(stream)
| 11 | myVfs.writeFileSync('/file.txt', 'hello world'); |
| 12 | |
| 13 | function readStream(stream) { |
| 14 | return new Promise((resolve, reject) => { |
| 15 | const chunks = []; |
| 16 | stream.on('data', (c) => chunks.push(c)); |
| 17 | stream.on('end', () => resolve(Buffer.concat(chunks).toString())); |
| 18 | stream.on('error', reject); |
| 19 | }); |
| 20 | } |
| 21 | |
| 22 | // Read using an existing fd; autoClose:false leaves fd open |
| 23 | { |