Skip to content

How to use Readline? #6

Answered by TheSpyder
williamrjribeiro asked this question in Q&A
Discussion options

You must be logged in to vote

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:

let rl = Readline.make(
Readline.interfaceOptions(~input=Fs.createReadStream("sample.txt"), ~crlfDelay=infinity, ()),
)
rl
->Readline.Interface.on(Event.fromString("line"), line => {
Js.log(`Received: ${line}`)
})
->ignore

Which generates the correct JS (Pervasives.infinity is just a reference to Infinity):

var Fs = require("…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@williamrjribeiro
Comment options

@TheSpyder
Comment options

Answer selected by williamrjribeiro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #5 on December 13, 2021 22:48.