1.0.4 • Published 3 years ago

node-input.js v1.0.4

Weekly downloads
13
License
GPL-3.0
Repository
github
Last release
3 years ago

Installation

npm: npm i node-input.js

About

node-input.js is a package for reading inputs from terminal/command line

Examples

Example with Async/Await

const { input } = require("node-input.js");

(async function main () {
    let name = await input("What is your name? ");
    let sport = await input("What is your favorite sport? ");

    console.log(`Hello ${name}, do want to play ${sport} together sometime?`);

    process.exit();
})();

Example with a stream

const { stream } = require("node-input.js");

let input = stream.connect((buffer) => {
    let args = buffer.toString().trim().split(" ");

    switch (args[0].toLowerCase()) {
        case "exit":
            process.exit();
            break;
        case "eval":
            let res = eval(args.slice(1).join(" "));
            console.log(res);
            break;
        case "disconnect":
            stream.disconnect(input);
            break;
    }
})

Working on

  • Synchronous input
  • Fixing input in REPL
1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago