From e65734a1edea8eb2c65e670d4b104814239c177f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20S=C3=A1nchez=20Villaf=C3=A1n?= Date: Fri, 21 May 2021 12:06:34 -0500 Subject: [PATCH] feat: add support for STDIN --- readlines.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readlines.js b/readlines.js index 6b8bdc1..de3c064 100644 --- a/readlines.js +++ b/readlines.js @@ -89,7 +89,7 @@ class LineByLine { do { const readBuffer = new Buffer(this.options.readChunk); - bytesRead = fs.readSync(this.fd, readBuffer, 0, this.options.readChunk, this.fdPosition); + bytesRead = fs.readSync(this.fd, readBuffer, 0, this.options.readChunk, this.fd === process.stdin.fd ? undefined : this.fdPosition); totalBytesRead = totalBytesRead + bytesRead; this.fdPosition = this.fdPosition + bytesRead; @@ -116,7 +116,7 @@ class LineByLine { } next() { - if (!this.fd) return false; + if (typeof this.fd !== 'number' && !this.fd) return false; let line = false;