@slimio/stdin

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

Usage no npm install needed!

<script type="module">
  import slimioStdin from 'https://cdn.skypack.dev/@slimio/stdin';
</script>

README

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

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