Skip to content

Instantly share code, notes, and snippets.

@picpoint
Created May 21, 2019 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save picpoint/727a7947b380622cc9a1b61d2a886c68 to your computer and use it in GitHub Desktop.
Save picpoint/727a7947b380622cc9a1b61d2a886c68 to your computer and use it in GitHub Desktop.
simple script to work width streams
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