TheSpyder / rescript-nodejs

Node bindings for ReScript
MIT License
79 stars 15 forks source link

How to use `Readline`? #5

Closed williamrjribeiro closed 2 years ago

williamrjribeiro commented 2 years ago

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 rescript-nodejs but I can't find a way to use Readline module:

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 Readline module. Can you give me some hints? I just want to read a text file line by line.

If this is not the right place, where should I ask this kind of question? Thanks.

TheSpyder commented 2 years ago

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.