(stream, options, callback)
| 21 | } |
| 22 | |
| 23 | static readToEnd(stream, options, callback) { |
| 24 | if (typeof options === 'function') { |
| 25 | callback = options; |
| 26 | options = {}; |
| 27 | } |
| 28 | |
| 29 | const dest = new ReadToEnd(options); |
| 30 | |
| 31 | stream.pipe(dest); |
| 32 | |
| 33 | stream.on('error', (err) => { |
| 34 | stream.unpipe(dest); |
| 35 | callback(err); |
| 36 | }); |
| 37 | |
| 38 | dest.on('complete', callback); |
| 39 | dest.resume(); |
| 40 | |
| 41 | return dest; |
| 42 | } |
| 43 | } |