io

io is a module for read or write in console

npm install io

text(String): It is the text that will be printed.

color(String): It is the color name that will contain the text(Default white).

options(Object): It is an object that contains text styles

  • color(String): It is the color name that will contain the text(Default white).
  • background(String): It is the background color name that will contain the text(Default black).
  • style(String): It is the style that will contain the text.

background(String): It is the background color name that will contain the text(Default black).

style(String): It is the style that will contain the text.

var io = require('io');
io.write('This text is red', 'red');
io.write('This text is yellow, background white and italic', {
   color: 'yellow',
   background: 'white',
   style: 'italic'
});
//Or 
io.write('This text is yellow, background white and italic', 'yellow', 'white', 'italic');
  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • gray
  • grey
  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • bold
  • italic
  • underline
  • strikethrough

question(Object): It is an object that has the parameters for the terminal Question.

  • question(String): Question Text (Is required).
  • default(String): Pre-defined text field response.
  • format(RegExp): Regular expression that validates the format of the response
  • formatError(String): Text format wonders if the input is wrong
  • after(Function): Function that runs after the entry of the answer, if you return to continue with the next question if you do not wait to return anything running "this.continue ()"
var io = require('io');
var question = {
        question: 'Age: ',
        defult: '18',
        format: /^[0-9]+$/,
        formatError: 'The format is incorrect, age:',
        afterfunction(answer){
            //async: this.continue(); or sync: return true; 
        }
};
io.read(question, function(answer){
    io.write('You answer is: '+answer); // => text of answer 
});