Skip to content

Instantly share code, notes, and snippets.

@andris9
Created November 11, 2019 20:17
Show Gist options
  • Save andris9/f0de0dbced99db6580cad700ea69710d to your computer and use it in GitHub Desktop.
Save andris9/f0de0dbced99db6580cad700ea69710d to your computer and use it in GitHub Desktop.
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