[[oktatas:web:nodejs|< Node.js]]
====== CommonJS ======
* **Szerző:** Sallai András
* Copyright (c) 2021, Sallai András
* Szerkesztve: 2021-2025
* Licenc: [[https://creativecommons.org/licenses/by-sa/4.0/|CC Attribution-Share Alike 4.0 International]]
* Web: https://szit.hu
===== A CommonJS =====
A CommonJS a nem böngészőben futó JavaScript szabványosítása.
Webhely:
* https://commonjs.org/
===== Bekérés =====
A Node.js segítségével az alapértelmezett bemenetről olvashatunk, és írhatunk
az alapértelmezett kimenetre.
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
readline.question('Mi a neved? Név: ', name => {
console.log(`Üdvözöllek ${name}!`);
readline.close();
});
===== A read csomag =====
import { read } from 'read';
(async () => {
var nev = await read({
prompt: 'Adja meg a nevét: '
});
console.log(nev);
})();
Jelszó bekérése:
import { read } from 'read';
(async () => {
var pass = await read({
prompt: 'Jelszó: ',
silent: true,
replace: '*'
});
console.log(pass);
})();