diff options
author | LinuxWizard42 <computerwizard@linuxmail.org> | 2022-10-12 22:54:37 +0300 |
---|---|---|
committer | LinuxWizard42 <computerwizard@linuxmail.org> | 2022-10-12 22:54:37 +0300 |
commit | 703e03aba33f234712206769f57717ba7d92d23d (patch) | |
tree | 0041f04ccb75bd5379c764e9fe42249fffe75fc3 /node_modules/progress-stream/test | |
parent | ab6e257e6e9d9a483d7e86f220d8b209a2cd7753 (diff) | |
download | FlashRunner-703e03aba33f234712206769f57717ba7d92d23d.tar.gz FlashRunner-703e03aba33f234712206769f57717ba7d92d23d.tar.zst |
Added export_allowed file to make repository visible in cgit
Diffstat (limited to 'node_modules/progress-stream/test')
-rw-r--r-- | node_modules/progress-stream/test/http.js | 30 | ||||
-rw-r--r-- | node_modules/progress-stream/test/request.js | 20 |
2 files changed, 50 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'); diff --git a/node_modules/progress-stream/test/request.js b/node_modules/progress-stream/test/request.js new file mode 100644 index 0000000..c5d676b --- /dev/null +++ b/node_modules/progress-stream/test/request.js @@ -0,0 +1,20 @@ +var progress = require('../index'); +var req = require('request'); +var fs = require('fs'); +var log = require('single-line-log').stdout; +var numeral = require('numeral'); + +var str = progress({ + drain: true, + time: 100 +}, 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)+'%'); +}); + +req('http://cachefly.cachefly.net/10mb.test', { + headers: { 'user-agent': 'test' } +}).pipe(str); + +console.log('progress-stream using request module - downloading 10 MB file'); |