Stdin
Node.js light standard input (stdin) crafted for REPL experience
Requirements
- Node.js v10 or higher
Getting Started
This package is available in the Node Package Repository and can be easily installed with npm or yarn.
$ npm i @slimio/stdin
# or
$ yarn add @slimio/stdin
Usage example
const stdin = require("@slimio/stdin");
async function main() {
const result = await stdin("Question title > ", {
history: ["command in history 1", "command in history 2"],
autocomplete: [
"events",
"events.get_info"
]
});
console.log(result);
}
main().catch(console.error);
API
stdin(query: null | string, options?: Options): Promise< string >
Query paramaters can be set to null
to disable the title. Options is described by the following TypeScript interface:
interface Options {
history?: string[];
autocomplete?: string[];
}
Dependencies
Name | Refactoring | Security Risk | Usage |
---|---|---|---|
fast-levenshtein | Major | Low | Implementation of levenshtein algo to found similar strings for auto-completion |
string-length | Major | Low | Get the real string length |
License
MIT