-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path4-pipe.js
More file actions
19 lines (15 loc) · 413 Bytes
/
Copy path4-pipe.js
File metadata and controls
19 lines (15 loc) · 413 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';
const fs = require('node:fs');
const stream = require('node:stream');
const readable = fs.createReadStream('data.tmp');
const writable = new stream.Writable({
write(chunk, encoding, next) {
console.log({ size: chunk.length, encoding, next });
//next(new Error('Error flushing data'));
next();
},
});
readable.pipe(writable);
readable.on('end', () => {
console.log('Done');
});