1.1.17 • Published 4 years ago

staylow v1.1.17

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

staylow

A Node.JS module with custom prompt and log functions, mainly intended for CLI chat applications. User input won't be interrupted by asynchronous messages received and logged in the terminal.

Init

const sl = require('staylow');
sl.options({
  defaultPrompt: String // (defaults to '> ')
  globalMask: String // set the mask used for muted input (defaults to '*')
  logOnEnter: String // 'true' or 'false', change default behavior on 'enter' keypress (defaults to 'true')
});

Prompt

Normal prompt:

sl.prompt('Say hi: ', res => {
  //user input will be visible
});

sl.prompt('', res => {
  //in this case the prompt will default to options.defaultPrompt
});

Masked prompt:

sl.prompt('Say hi: ', true, res => {
  //user input will be masked with options.globalMask
});

Saving history:

//By default, user entries won't be saved to the entry history
//To save manually, use the following:
sl.addToHistory('String you want to save');

Log

Always use the staylow log method instead of console.log to output to terminal. This insures that any active user prompts won't be interrupted.

sl.log('Hello world');

Pause / Resume

You can manually pause or resume input using the following commands.

sl.pause(); //Pause
sl.resume(); //Resume
1.1.16

4 years ago

1.1.17

4 years ago

1.1.15

5 years ago

1.1.14

5 years ago

1.1.13

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago