How to convert NodeJS stream to Web Stream
import * as fs from 'node:fs';
const nodeReadable = fs.createReadStream('data.txt', {encoding: 'utf-8'});
We can use the Readable.toWeb(), Writable.toWeb().
import * as fs from 'node:fs';
import {Readable} from 'node:stream';
const nodeReadable = fs.createReadStream('data.txt', {encoding: 'utf-8'});
const webReadableStream = Readable.toWeb(nodeReadable);
const nodeWritable = fs.createWriteStream('data.txt', {encoding: 'utf-8'});
const webWritableStream = Writable.toWeb(nodeWritable);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With