MCPcopy
hub / github.com/flowjs/flow.js / pipeChunk

Function pipeChunk

samples/Node.js/flow-node.js:152–176  ·  view source on GitHub ↗
(number)

Source from the content-addressed store, hash-verified

150
151 // Iterate over each chunk
152 var pipeChunk = function(number) {
153
154 var chunkFilename = getChunkFilename(number, identifier);
155 fs.exists(chunkFilename, function(exists) {
156
157 if (exists) {
158 // If the chunk with the current number exists,
159 // then create a ReadStream from the file
160 // and pipe it to the specified writableStream.
161 var sourceStream = fs.createReadStream(chunkFilename);
162 sourceStream.pipe(writableStream, {
163 end: false
164 });
165 sourceStream.on('end', function() {
166 // When the chunk is fully streamed,
167 // jump to the next one
168 pipeChunk(number + 1);
169 });
170 } else {
171 // When all the chunks have been piped, end the stream
172 if (options.end) writableStream.end();
173 if (options.onDone) options.onDone();
174 }
175 });
176 };
177 pipeChunk(1);
178 };
179

Callers 1

flow-node.jsFile · 0.85

Calls 1

getChunkFilenameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…