From 71257a979e2a825a381f883be448124c7947adef Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 13:06:21 +0100 Subject: [PATCH 01/18] Update index.js --- 07/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/07/index.js b/07/index.js index f756263..ad7e5fd 100644 --- a/07/index.js +++ b/07/index.js @@ -1,4 +1,4 @@ -var http = require('http'); +const http = require('http'); http.get(process.argv[2], (res) =>{ res.setEncoding('utf8'); From 89082b00e194608f0b58757466bc2f87d44b1262 Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 16:53:44 +0100 Subject: [PATCH 02/18] Update index.js --- 08/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/08/index.js b/08/index.js index 05fb3ca..7c2c247 100644 --- a/08/index.js +++ b/08/index.js @@ -1,6 +1,6 @@ -var http = require('http'); +const http = require('http'); -var string = ''; +const string = ''; http.get(process.argv[2], (res) =>{ res.setEncoding('utf8'); From e7c3be56da4352027b9245305ce37c1672b8dc79 Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 16:54:05 +0100 Subject: [PATCH 03/18] Update blindex.js --- 08/blindex.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/08/blindex.js b/08/blindex.js index 6528cdc..7d4b74c 100644 --- a/08/blindex.js +++ b/08/blindex.js @@ -1,12 +1,12 @@ -var http = require('http'); -var bl = require('bl'); +const http = require('http'); +const bl = require('bl'); http.get(process.argv[2], (res) =>{ res.pipe(bl( (err,data) => { if(err) console.error('Error: '+err); - var string = data.toString(); + const string = data.toString(); console.log(string.length); console.log(string); } )); From 0023d1a5d8990e21a8a5c8a54472e65a9d8b6a6d Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 16:56:46 +0100 Subject: [PATCH 04/18] Update index.js --- 07/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/07/index.js b/07/index.js index ad7e5fd..f65060d 100644 --- a/07/index.js +++ b/07/index.js @@ -1,6 +1,6 @@ const http = require('http'); -http.get(process.argv[2], (res) =>{ +http.get(process.argv[2], (res) => { res.setEncoding('utf8'); res.on('data', console.log); res.on('error', console.error); From a13e9407e26a12c3c5dd5ef07a924fa65647675d Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 16:57:12 +0100 Subject: [PATCH 05/18] Update filter.js --- 06/modules/filter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/06/modules/filter.js b/06/modules/filter.js index 0e1f6aa..4357df0 100644 --- a/06/modules/filter.js +++ b/06/modules/filter.js @@ -1,5 +1,5 @@ -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); module.exports = (dir, ext, callback) => { From c49a2028fb96e6b76e753a6e6f39b69dfda1b60d Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 16:59:46 +0100 Subject: [PATCH 06/18] Update blindex.js --- 08/blindex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/08/blindex.js b/08/blindex.js index 7d4b74c..98dab51 100644 --- a/08/blindex.js +++ b/08/blindex.js @@ -1,7 +1,7 @@ const http = require('http'); const bl = require('bl'); -http.get(process.argv[2], (res) =>{ +http.get(process.argv[2], (res) => { res.pipe(bl( (err,data) => { if(err) console.error('Error: '+err); From 2e5c922698753b980d21169a396538ee6f1fceb6 Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 17:00:12 +0100 Subject: [PATCH 07/18] Update blindex.js --- 08/blindex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/08/blindex.js b/08/blindex.js index 6528cdc..0e922a2 100644 --- a/08/blindex.js +++ b/08/blindex.js @@ -1,7 +1,7 @@ var http = require('http'); var bl = require('bl'); -http.get(process.argv[2], (res) =>{ +http.get(process.argv[2], (res) => { res.pipe(bl( (err,data) => { if(err) console.error('Error: '+err); From 25fd6fb2ae6aa85cf2561a4fc232331c0fc0fae9 Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 17:06:48 +0100 Subject: [PATCH 08/18] Update blindex.js --- 08/blindex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/08/blindex.js b/08/blindex.js index 98dab51..a566f80 100644 --- a/08/blindex.js +++ b/08/blindex.js @@ -9,5 +9,5 @@ http.get(process.argv[2], (res) => { const string = data.toString(); console.log(string.length); console.log(string); - } )); + })); }); From 25006951606ab01363b7938eb585424f3c2aa7e6 Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 17:09:07 +0100 Subject: [PATCH 09/18] Update index.js --- 08/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/08/index.js b/08/index.js index 7c2c247..3597ca4 100644 --- a/08/index.js +++ b/08/index.js @@ -8,7 +8,7 @@ http.get(process.argv[2], (res) =>{ string += data; }); - res.on('end', (end) =>{ + res.on('end', (end) => { console.log(string.length); console.log(string); }); From 3b1d229ffe617b227f1c860c4b8e283b267ce7e1 Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 17:29:50 +0100 Subject: [PATCH 10/18] Update afterTest.js --- 09/afterTest.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/09/afterTest.js b/09/afterTest.js index e7e0b78..9a276e2 100644 --- a/09/afterTest.js +++ b/09/afterTest.js @@ -1,18 +1,17 @@ -var http = require('http'); -var bl = require('bl'); -var after = require("after") - , next = after(3, printResults); +const http = require('http'); +const bl = require('bl'); +const after = require("after"), next = after(3, printResults); -var results = []; +let results = []; function printResults(){ - for (var i = 0; i < results.length; i++) { + for (let i = 0; i < results.length; i++) { console.log(results[i]); } } function get(index) { - http.get(process.argv[2+index], (res) =>{ + http.get(process.argv[2+index], (res) => { res.pipe(bl( (err,data) => { if(err) console.error('Error: '+err); @@ -25,5 +24,5 @@ function get(index) { } -for (var i = 0; i < 3; i++) +for (let i = 0; i < 3; i++) get(i); From bcb5a22b58040a417dabe74f8a29d1d833d2446b Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 17:30:12 +0100 Subject: [PATCH 11/18] Update index.js --- 06/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/06/index.js b/06/index.js index dd00e9f..2ea0118 100644 --- a/06/index.js +++ b/06/index.js @@ -4,7 +4,7 @@ filter(process.argv[2], process.argv[3], (error,data) => { if(error) return console.error('Error: '+error); - for (var i = 0; i < data.length; i++) { + for (let i = 0; i < data.length; i++) { console.log(data[i]); } }); From 0f4b05628e995889a6fe6cbdc9898e257d1429b3 Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 17:31:49 +0100 Subject: [PATCH 12/18] Update asyncTest.js --- 09/asyncTest.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/09/asyncTest.js b/09/asyncTest.js index 0f512b2..5cc647c 100644 --- a/09/asyncTest.js +++ b/09/asyncTest.js @@ -1,15 +1,15 @@ -var http = require('http'); -var bl = require('bl'); -var async = require('async'); +const http = require('http'); +const bl = require('bl'); +const async = require('async'); function printResults(results){ - for (var i = 0; i < results.length; i++) { + for (let i = 0; i < results.length; i++) { console.log(results[i]); } } function getAsync(url, callback) { - http.get(url, (res) =>{ + http.get(url, (res) => { res.pipe(bl( (err,data) => { if(err) callback(err); @@ -30,7 +30,7 @@ async.map(process.argv.slice(2,5),getAsync, (error, results) =>{ // (callback) => { // get(0, callback); // }, -// ], (error,results)=>{ +// ], (error,results)=> { // // if(error) // console.error('Error: '+error); From 7b66e53c0c0ef3a1e0025eb11f2df098fad129e0 Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 17:40:38 +0100 Subject: [PATCH 13/18] Update index.js --- 09/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/09/index.js b/09/index.js index 05c1a3f..fc8e30d 100644 --- a/09/index.js +++ b/09/index.js @@ -1,17 +1,17 @@ -var http = require('http'); -var bl = require('bl'); +const http = require('http'); +const bl = require('bl'); -var results = []; -var count = 0; +let results = []; +let count = 0; function printResults(){ - for (var i = 0; i < results.length; i++) { + for (let i = 0; i < results.length; i++) { console.log(results[i]); } } function get(index) { - http.get(process.argv[2+index], (res) =>{ + http.get(process.argv[2+index], (res) => { res.pipe(bl( (err,data) => { if(err) console.error('Error: '+err); @@ -27,5 +27,5 @@ function get(index) { } -for (var i = 0; i < 3; i++) +for (let i = 0; i < 3; i++) get(i); From 18ad04acb759d171db7dfeebe8e24cfbc1340537 Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 17:41:35 +0100 Subject: [PATCH 14/18] Update promisesTest.js --- 09/promisesTest.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/09/promisesTest.js b/09/promisesTest.js index d1fde98..6daaf8e 100644 --- a/09/promisesTest.js +++ b/09/promisesTest.js @@ -1,8 +1,8 @@ -var http = require('http'); -var bl = require('bl'); +const http = require('http'); +const bl = require('bl'); function printResults(results){ - for (var i = 0; i < results.length; i++) { + for (let i = 0; i < results.length; i++) { console.log(results[i]); } } @@ -20,7 +20,7 @@ function getPromise(index) { } var arrayPromises = []; -for (var i = 0; i < 3; i++) { +for (let i = 0; i < 3; i++) { arrayPromises.push( getPromise(i) ); } From fb606c9ba547099636679dccfe704f29914547e6 Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Fri, 22 Feb 2019 17:43:38 +0100 Subject: [PATCH 15/18] Update index.js --- 10/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/10/index.js b/10/index.js index 1ca414c..9761680 100644 --- a/10/index.js +++ b/10/index.js @@ -1,12 +1,12 @@ -var net = require('net'); -var strftime = require('strftime'); +const net = require('net'); +const strftime = require('strftime'); function getDate() { // YYYY-MM-DD hh:mm return strftime('%Y-%m-%d %H:%M'); } -var server = net.createServer( (socket) =>{ +const server = net.createServer( (socket) =>{ socket.end(getDate()+"\n"); } ); From 0506f9a2f2534b83807f4bad6c242e8962217021 Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Mon, 25 Feb 2019 10:49:53 +0100 Subject: [PATCH 16/18] Update index.js --- 11/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/11/index.js b/11/index.js index 9d1dd27..28adce5 100644 --- a/11/index.js +++ b/11/index.js @@ -1,7 +1,7 @@ -var http = require('http'); -var fs = require('fs'); +const http = require('http'); +const fs = require('fs'); -var server = http.createServer( (req,res) =>{ +const server = http.createServer( (req,res) =>{ res.writeHead(200, { 'content-type' : 'text-plain' }); fs.createReadStream(process.argv[3]).pipe(res); }); From c115ba2f58800cd13f3bb7a491166ef0cf110cb5 Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Mon, 25 Feb 2019 10:54:11 +0100 Subject: [PATCH 17/18] Update index.js --- 12/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/12/index.js b/12/index.js index 8a7682c..fa74aae 100644 --- a/12/index.js +++ b/12/index.js @@ -1,7 +1,7 @@ -var http = require('http'); -var map = require('through2-map'); +const http = require('http'); +const map = require('through2-map'); -var server = http.createServer( (req,res) =>{ +const server = http.createServer( (req,res) =>{ if(req.method !== 'POST') return res.end('Only POST please'); From e5a838d814b97edfd72a62cbece9a33e506c1ba3 Mon Sep 17 00:00:00 2001 From: Giampiero Piras Date: Mon, 25 Feb 2019 11:06:05 +0100 Subject: [PATCH 18/18] Update index.js --- 13/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/13/index.js b/13/index.js index 8fc4eb6..7380e82 100644 --- a/13/index.js +++ b/13/index.js @@ -1,10 +1,10 @@ -var http = require('http'); -var url = require('url'); +const http = require('http'); +const url = require('url'); -var server = http.createServer( (req,res) =>{ - var parse = url.parse(req.url, true); - var date = new Date(parse.query.iso); - var result; +const server = http.createServer( (req,res) =>{ + let parse = url.parse(req.url, true); + let date = new Date(parse.query.iso); + let result; switch (parse.pathname) { case '/api/parsetime':