学习标准输入输出流
根据老外的教程,动手做demo,感觉棒棒哒 ^_^
//实践是检验真理的唯一标准
var q = ['what\'s your name', 'how old are you', 'what do you like']
var question_proxy = function () {
var count = 0;
function question () {
process.stdout.write(q[count] + '>');
count++;
}
function question_proxy() {
if (count === q.length) {
process.exit();
} else {
question();
}
}
return question_proxy;
}();
question_proxy();
process.stdin.on('data', function(d) {
question_proxy();
});
loading百分比demo
var setLoading = function(total, delay) {
var over = 0;
var timer = setInterval(function() {
over += delay;
process.stdout.cursorTo(0);
process.stdout.write(`waiting...${Math.floor(over / total * 100)}%`);
if (over >= total) {
clearInterval(timer);
process.exit();
}
}, delay);
};
setLoading(3000, 50);
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。