How to create a thread for packing data in a file while writing data in it?

How to create a thread to record the data is Packed and written to a file?
April 4th 20 at 00:50
2 answers
April 4th 20 at 00:52
And where there is need an example? There's documentation on threads - elna.Wolf commented on April 4th 20 at 00:55
@nella.Runolfsson, right at the beginning: - Federico.Trant commented on April 4th 20 at 00:58
@dereck.OConnell94, saw, but did not understand how to adjust. there is an input stream file. I have the same input stream must be writable, so I wrote the data. Ie. sort should be a Duplex stream, but how to adapt - lack of knowledge.

p.s.the funny thing is my old program where it is implemented, but it already a couple of years and even it can't understand what I did there :( - elna.Wolf commented on April 4th 20 at 01:01
@nella.Runolfsson, archive streams and so duplex
instead of the pipe from a file write to the stream archive
and its output (read) point to a stream write to a file using pipe - Federico.Trant commented on April 4th 20 at 01:04
@dereck.OConnell94, Thanks for the tip. I kind of did that, but forgot that everything is asynchronous and therefore in the file were blank. So it seems to work. I'll try to unpack
// Create a stream wrapping
var streamPack = cZlib.createDeflateRaw();
// Create a stream for writing to a file
var streamWriteFile = cFS.createWriteStream('s:/Cloud/test/list.deflate');
// Redirect photocapacitance stream to file 
// Write to the stream data
streamPack.write('data', () => {
 // Finish the input
 streamPack.flush(() => {
 // and close the stream
- elna.Wolf commented on April 4th 20 at 01:07
April 4th 20 at 00:54

Find more questions by tags JavaScriptNode.jsData compression