Created
May 21, 2019 10:33
-
-
Save picpoint/727a7947b380622cc9a1b61d2a886c68 to your computer and use it in GitHub Desktop.
simple script to work width streams
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); // подключаем модуль файловой системы | |
const zlib = require('zlib'); // подключаем модуль компрессии | |
const gzip = zlib.createGzip(); // создаём переменную для компрессии | |
const inp = fs.createReadStream('test.txt'); // входящий поток, чтение файла | |
const out = fs.createWriteStream('test2.txt.gz'); // исходящий поток, запись компрессионного файла test2.txt.gz | |
inp.pipe(gzip).pipe(out); // входящий поток, пайпит через поток компрессии и снова пайпит в исходящий поток для создания файла |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment