// read the file with the url fs.createReadStream(process.argv[2]) // ensures outputing each line on a different chunk .pipe(split()) .pipe(new ParallelStream(transformer)) .pipe(fs.createWriteStream('urlList-results.txt')) //destination stream .on('finish', () => { console.log('All urls were checked'); console.log(`Execution time : ${Date.now()-startTime}(ms)`); });
fs.createReadStream(process.argv[2]) .pipe(split()) .pipe(new LimitedParallelStream(2, (url, enc, push, done) => { if(!url) return done(); request.head(url, (err, response) => { push(url + ' is ' + (err ? 'down' : 'up') + '\n'); done(); }); })) .pipe(fs.createWriteStream('results.txt')) .on('finish', () => console.log('All urls were checked')) ;
// read the file with the url fs.createReadStream(process.argv[2]) // ensures outputing each line on a different chunk .pipe(split()) .pipe(throughParallel.obj({concurrency: 2}, transformer)) .pipe(fs.createWriteStream('urlList-results.txt')) //destination stream .on('finish', () => { console.log('All urls were checked'); console.log(`Execution time : ${Date.now()-startTime}(ms)`); });
fs.createReadStream(process.argv[2]) .pipe(split()) .pipe(throughParallel.obj({concurrency: 2}, function (url, enc, done) { if(!url) return done(); request.head(url, (err, response) => { this.push(url + ' is ' + (err ? 'down' : 'up') + '\n'); done(); }); })) .pipe(fs.createWriteStream('results.txt')) .on('finish', () => console.log('All urls were checked')) ;
// read the file with the url fs.createReadStream(process.argv[2]) // ensures outputing each line on a different chunk .pipe(split()) .pipe(new LimitedParallelStream(concurrency, transformer)) .pipe(fs.createWriteStream('urlList-results.txt')) //destination stream .on('finish', () => { console.log('All urls were checked') console.log(`Execution time : ${Date.now()-startTime}(ms)`); });
fs.createReadStream(process.argv[2]) //[1] .pipe(split()) //[2] .pipe(new ParallelStream((url, enc, done, push) => { //[3] if(!url) return done(); request.head(url, (err, response) => { push(url + ' is ' + (err ? 'down' : 'up') + '\n'); done(); }); })) .pipe(fs.createWriteStream('results.txt')) //[4] .on('finish', () => console.log('All urls were checked')) ;
fs.createReadStream(process.argv[2]) .pipe(split()) .pipe( new ParallelStream((url, enc, push, done) => { if (!url) return done && done(); request.head(url, (err, response) => { push(`${url} is ${err ? "down" : "up"} \n`); done && done(); }); }) ) .pipe(fs.createWriteStream("results.txt")) .on("finish", () => console.log("All urls were checked"));