diff options
| author | Arman Shah <[email protected]> | 2018-02-19 23:50:04 -0800 |
|---|---|---|
| committer | Arman Shah <[email protected]> | 2018-02-19 23:50:04 -0800 |
| commit | ae34dcfd3823a609ba7182f2d6eda593be876f7d (patch) | |
| tree | b9d7f2884c4999349418cbdc4f9ab46d113e0afd /node_modules/progress-stream/test/http.js | |
| parent | Initial commit (diff) | |
| download | launcher-ae34dcfd3823a609ba7182f2d6eda593be876f7d.tar.xz launcher-ae34dcfd3823a609ba7182f2d6eda593be876f7d.zip | |
add base files
Diffstat (limited to 'node_modules/progress-stream/test/http.js')
| -rw-r--r-- | node_modules/progress-stream/test/http.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/node_modules/progress-stream/test/http.js b/node_modules/progress-stream/test/http.js new file mode 100644 index 0000000..48f3024 --- /dev/null +++ b/node_modules/progress-stream/test/http.js @@ -0,0 +1,30 @@ +var progress = require('../index'); +var http = require('http'); +var fs = require('fs'); +var log = require('single-line-log').stdout; +var numeral = require('numeral'); + +var str = progress({ + drain: true, + time: 100, + speed: 20 +}); +str.on('progress', function(progress) { + log('Running: '+numeral(progress.runtime).format('00:00:00')+' ('+numeral(progress.transferred).format('0 b')+')\n'+ + 'Left: '+numeral(progress.eta).format('00:00:00')+' ('+numeral(progress.remaining).format('0 b')+')\n'+ + numeral(progress.speed).format('0.00b')+'/s '+Math.round(progress.percentage)+'%'); +}); + +var options = { + method: 'GET', + host: 'cachefly.cachefly.net', + path: '/10mb.test', + headers: { + 'user-agent': 'testy test' + } +}; +http.request(options, function(response) { + response.pipe(str); +}).end(); + +console.log('progress-stream using http module - downloading 10 MB file'); |