Node.js Readline Module
ဥပမာ
ဖိုင်တစ်ခုကိုဖွင့်ပြီး အကြောင်းအရာကို စာကြောင်းတစ်ကြောင်းချင်း ပြန်ပေးသည်-
var readline = require('readline');
var fs = require('fs');
var
myInterface = readline.createInterface({
input:
fs.createReadStream('demofile1.html')
});
var lineno = 0;
myInterface.on('line', function (line) {
lineno++;
console.log('Line number ' + lineno + ': ' + line);
});
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
Readline module သည် ဒေတာစီးကြောင်းတစ်ခုအား တစ်ကြိမ်လျှင် တစ်ကြောင်းဖတ်ရန် နည်းလမ်းကို ပံ့ပိုးပေးပါသည်။
အထားအသို
သင့်အပလီကေးရှင်းတွင် Readline module ပါ၀င်ခြင်းအတွက် syntax-
var readline = require('readline');
Properties နှင့် Methods ကိုဖတ်ပါ။
Method | Description |
---|---|
clearLine() | Clears the current line of the specified stream |
clearScreenDown() | Clears the specified stream from the current cursor down position |
createInterface() | Creates an Interface object |
cursorTo() | Moves the cursor to the specified position |
emitKeypressEvents() | Fires keypress events for the specified stream |
moveCursor() | Moves the cursor to a new position, relative to the current position |