init new course

This commit is contained in:
Philippe Torrel
2026-09-06 23:00:53 +02:00
parent 4875204025
commit c5115d81f6
9921 changed files with 4 additions and 1160514 deletions
@@ -1,54 +0,0 @@
// const dns = require('node:dns'); // commonjs
import dns from 'node:dns'; // esm module
import util from 'node:util';
import color from 'chalk';
const IP_V = 4; // we use IP protocol version 4
const URL = 'google.de';
const getIpBy = (url, ipVersion = 4) => {
return new Promise((resolve, reject) => {
// async process
dns.lookup(url, ipVersion, (error, address) => {
if (error) {
reject(error);
} else {
resolve({ address: address, family: ipVersion });
}
});
});
};
// Promises Unterobjekt von Node
const getPromisesIpBy = (url, ipVersion = 4) => {
// async process
return dns.promises.lookup(url, ipVersion);
};
// Promisify Helferfunktion
const getPromisifyIpBy = util.promisify(dns.lookup);
// Test Cases:
getIpBy(URL, IP_V)
.then((data) => {
console.log(data);
})
.catch((err) => {
console.log(color.red(err));
});
getPromisesIpBy(URL)
.then((data) => {
console.log(data);
})
.catch((err) => {
console.log(color.red(err));
});
getPromisifyIpBy(URL, IP_V)
.then((data) => {
console.log(data);
})
.catch((err) => {
console.log(color.red(err));
});