How to use Readline
?
#6
-
Hi there, I just started learning ReScript and I would like to use it for a NodeJS application. I'm trying to port this piece of NodeJS code to ReScript using const fs = require('fs');
const readline = require('readline');
const rl = readline.createInterface({
input: fs.createReadStream('sample.txt'),
crlfDelay: Infinity
});
rl.on('line', (line) => {
console.log(`Line from file: ${line}`);
}); I couldn't find any documentation on If this is not the right place, where should I ask this kind of question? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi! This is a fine place to ask. The ReScript forums are also good but people there might just tell you to write your own bindings 🙂 I'll see if I can port your code to use this library and post the results later today (I'm in Australia). I might also enable github discussions for the repo and transfer your question there. |
Beta Was this translation helpful? Give feedback.
-
Oh wow, looks like the Readline module was written incorrectly. The rescript-nodejs/src/Readline.res Line 17 in 83e9eba It also seems weird that the whole file is inside an I'll look up the nodejs documentation and make sure I get the module right, then push a new release and show you how to use it. |
Beta Was this translation helpful? Give feedback.
-
Published as 14.2.0 (it's a breaking change to The sample code you requested: rescript-nodejs/examples/ReadFileByLine.res Lines 4 to 12 in 6214ab6 Which generates the correct JS ( rescript-nodejs/lib/js/examples/ReadFileByLine.bs.js Lines 4 to 16 in 6214ab6 I'm happy to discuss what each part of the code does if you need help with it. |
Beta Was this translation helpful? Give feedback.
Published as 14.2.0 (it's a breaking change to
Readline
, but the module wasn't usable before so I figured a minor was ok).The sample code you requested:
rescript-nodejs/examples/ReadFileByLine.res
Lines 4 to 12 in 6214ab6
Which generates the correct JS (
Pervasives.infinity
is just a reference toInfinity
):rescript-nodejs/lib/js/examples/ReadFileByLine.bs.js
Lines 4 to 16 in 6214ab6