1.0.3 • Published 5 years ago

@slimio/stdin v1.0.3

Weekly downloads
9
License
MIT
Repository
github
Last release
5 years ago

Stdin

version Maintenance MIT dep size

Node.js light standard input (stdin) crafted for REPL experience

Requirements

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

NameRefactoringSecurity RiskUsage
fast-levenshteinMajorLowImplementation of levenshtein algo to found similar strings for auto-completion
string-lengthMajorLowGet the real string length

License

MIT