(number)
| 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 |
no test coverage detected
searching dependent graphs…