1.1.0 • Published 9 years ago
nodejs-scanf v1.1.0
nodejs-scanf

scanf for node.js :alien:
Install
npm i nodejs-scanfExample
scanf
read stdin async.
params:
format,handlerformat:%s string %d integer %f float %c characterlet {scanf} = require('nodejs-scanf'); // input: 'hello world' scanf('%s', function(str) { console.log(str); // output: //hello }); // input: 'hello 2017' scanf('%s %d', function(str, integer) { console.log(str, integer); // output: //hello 2017 }); // input: '2017-04-06' scanf('%d-%d-%d', function(year, month, day) { })scanfSync
read stdin sync
params:
formatreturn a array
let {scanfSync} = require(nodejs-scanf); let [year, month, day] = scanfSync('%d-%d-%d'); let [welcome, year] = scanfSync('%s,%d'); // input welcome,2017 //welcome: 'welcome' // year: 2017sscanf
read input string
params:
input,format,handlersscanf('2017-4-06', '%d-%d-%d', function(year, month, day) { })
License
MIT