Skip to content

Commit

Permalink
Update solution.js
Browse files Browse the repository at this point in the history
  • Loading branch information
impressi-web authored Jan 10, 2021
1 parent bb22710 commit 6bca9dd
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions exercises/whilst/solution/solution.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
"use strict"
const http = require('http')
, async = require('async');

let requestBody = '';
"use strict";
const { get } = require("http");
const async = require("async");

let requestBody = "";
let count = 0;

async.whilst(
function(cb) {
cb(null,!/meerkat/.test(requestBody.trim()));
},//async v3.x.x

function(done){
let body = '';
http.get(process.argv[2], function(res){
res.on('data', function(chunk){
body += chunk.toString();
});
function (cb) {
cb(null, !/meerkat/.test(requestBody.trim()));
},

res.on('end', function(){
++count;
requestBody = body;
done();
});
}).on('error', done);
function (done) {
let body = "";
get(process.argv[2], (res) => {
res
.on("data", (chunk) => {
body += chunk.toString();
})
.on("end", () => {
++count;
requestBody = body;
done();
});
}).on("error", done);
},

function(err){
if (err) return console.log(err);
function (err) {
if (err) return console.error(err);
console.log(count);
}
)
);

0 comments on commit 6bca9dd

Please sign in to comment.