Created
November 11, 2019 20:17
-
-
Save andris9/f0de0dbced99db6580cad700ea69710d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const dns = require('dns').promises; | |
// how many parallel "workers" to use | |
let batchSize = 3; | |
// domain list to process | |
let domains = [ | |
'neti.ee', | |
'hot.ee', | |
'zone.ee', | |
'telia.ee', | |
'delfi.ee', | |
'postimees.ee', | |
'nali.ee' | |
]; | |
async function main() { | |
let results = []; | |
while (domains.length) { | |
let promises = []; | |
for (let i = 0; i < batchSize && domains.length; i++) { | |
let domain = domains.shift(); | |
if (domain) { | |
promises.push(dns.resolveAny(domain)); | |
} | |
} | |
if (promises.length) { | |
results = results.concat(await Promise.all(promises)); | |
} | |
} | |
console.log(results); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment