Node.js Readline 모듈

❮ 내장 모듈


예시

파일을 열고 내용을 한 줄씩 반환합니다.

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 모듈은 한 번에 한 줄씩 데이터 스트림을 읽는 방법을 제공합니다.


통사론

애플리케이션에 Readline 모듈을 포함하기 위한 구문:

var readline = require('readline');

Readline 속성 및 메서드

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

❮ 내장 모듈