stdinput-js
v3.0.0
Published
Read from stdin the usual way
Downloads
2
Readme
stdin-js
A library that provide a python like input
function. Its async so it should be used within an async context.
Example usage
import { stdinput } from "stdinput-js";
// or
const { stdinput } = require("stdinput-js");
async function main() {
const name = await stdinput("What's your name?");
console.log(`Hello, ${name}`);
}
main();
Why?
To teach JavaScript like any other programming language out there you will use stdin sooner or later.
Who would want to take input like this?
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question("What's your name? ", function(answer) {
console.log("Hello " + answer);
rl.close();
});