0.1.6 • Published 1 year ago

node-stdio v0.1.6

Weekly downloads
3
License
MIT
Repository
github
Last release
1 year ago

node-stdio

A node interface for stdio like: cin, cout, scanf and printf.

how to install

  • npm install node-stdio

api

  • readInt() read a int or long number from stdin.
  • readDouble() read a float or double number from stdin.
  • read_line() read number of 1024 characters from stdin, or util meets \n.
  • gets(size) read number of size characters from stdin, or util meets \n.
  • printsth(sth, ...) display sth in stdou, if there are more than on args, the diaplay split by " ", in the end there is no '\n'.
  • print(sth, ...) display sth in stdou, if there are more than on args, the diaplay split by " ", in the end there is a '\n'. just like console.log().

use examples

var cmd = require('node-stdio');

function test() {
    cmd.print('Please input a int:');
    cmd.print(cmd.readInt());

    cmd.print('Please input a double:');
    cmd.print(cmd.readDouble());
}

test();

OJ Example

  • calc a+b, a b split by a space
var cmd = require('node-stdio')
var a, b;
var solveMeFirst = (a,b) => a+b;
while((a=cmd.readInt())!=null && (b=cmd.readInt())!=null){
    let c = solveMeFirst(a, b);
    cmd.print(c);
}

Thanks

Everyone uses this tool.

0.1.6

1 year ago

0.1.5

1 year ago

0.1.2

2 years ago

0.1.3

2 years ago

0.1.0

2 years ago

0.1.1

2 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago