Skip to content

Commit 95ddb72

Browse files
committed
chore: use Zlib for gzip demo
1 parent a6c6dc6 commit 95ddb72

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

package-lock.json

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
"globals": "^16.4.0",
7474
"mocha": "^11.7.4",
7575
"node-fetch": "^2.6.6",
76-
"node-gzip": "^1.1.2",
7776
"rollup": "^4.52.4",
7877
"typescript": "^5.9.3"
7978
},

test/gzip.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
import {writeFile} from 'fs/promises';
2-
import {gzip} from 'node-gzip';
1+
import {
2+
createReadStream,
3+
createWriteStream,
4+
} from 'node:fs';
5+
import { createGzip } from 'node:zlib';
6+
import { pipeline } from 'node:stream/promises';
37

4-
await writeFile(
5-
import.meta.dirname + '/fixtures/hello.txt.gz',
6-
await gzip('hello world')
8+
/**
9+
* @param {string} input
10+
* @param {string} output
11+
*/
12+
async function gzip (input, output) {
13+
const gzip = createGzip();
14+
const source = createReadStream(input);
15+
const destination = createWriteStream(output);
16+
await pipeline(source, gzip, destination);
17+
}
18+
19+
await gzip(
20+
import.meta.dirname + '/fixtures/hello.txt',
21+
import.meta.dirname + '/fixtures/hello.txt.gz'
722
);

0 commit comments

Comments
 (0)