@slimio/stdin
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

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

Package Sidebar

Install

npm i @slimio/stdin

Weekly Downloads

5

Version

1.0.3

License

MIT

Unpacked Size

13.3 kB

Total Files

5

Last publish

Collaborators

  • fraxken
  • alexandre.malaj