-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path6-timeout.js
More file actions
16 lines (13 loc) · 447 Bytes
/
Copy path6-timeout.js
File metadata and controls
16 lines (13 loc) · 447 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'use strict';
const fs = require('node:fs');
const streams = require('node:stream/promises');
const zlib = require('node:zlib');
const main = async () => {
const readable = fs.createReadStream('data.tmp');
const writable = fs.createWriteStream('data.gz');
const gzip = zlib.createGzip();
const options = { signal: AbortSignal.timeout(10) };
await streams.pipeline(readable, gzip, writable, options);
console.log('Done');
};
main();