Skip to content

A small library that provides synchronous input function for NodeJS. It is used in Hyperskill JavaScript projects.

License

Notifications You must be signed in to change notification settings

hyperskill/sync-input

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

sync-input

A small library that provides synchronous input function for NodeJS.

It is used in educational JavaScript projects for Hyperskill.

This is simplified version of prompt-sync library and intended to be used not with an actual keyboard, but with an stdin pipe. In spite of this, it works with a keyboard input too.

Installation

You can install this library using the following command. You don't need git to be installed to perform this command.

npm install https://github.com/hyperskill/sync-input/archive/v1.tar.gz

Or you can add the following line into your package.json file.

"dependencies": {
    "sync-input": "https://github.com/hyperskill/sync-input/archive/v1.tar.gz"
}

You can also refer to the latest changes in the release branch using release.tar.gz instead of v1.tar.gz.

Usage

To import the function you can use require function:

const input = require('sync-input');

To use, just call this input function. It pretty much behaves like Python's input built-in function.

let name = input();
let age = Number(input());

You can also pass prompt that will be printed before requesting input.

let name = input("Print your name: ");
let age = Number(input("Print your age: "));

About

A small library that provides synchronous input function for NodeJS. It is used in Hyperskill JavaScript projects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published