sinp
v1.0.2
Published
A simple standard input reader
Downloads
6
Readme
Sinp
A simple standard input reader
Installation
npm i sinp
Usage
const input = reqiure('sinp');
(async function () {
const inp = input('> ');
console.log('You said:', await inp);
})();
Sinp can also be used with .then:
input('> ').then(function (inp) {
console.log('You said:', inp);
});
The "prompt" parameter is optional, and defaults to an empty string.
Sinp can also output a buffer instead of a string for more control:
input('> ', true).then(function (inp) {
console.log(inp.toString().trim()); // Buffer mode won't trim the input
});
Motivation
A lot of other stdin readers are bloated with features that often aren't used. Sinp was created to be a simple input reader with no extra features or dependencies. Sinp doesn't even depend on readlines.