https://github.com/sscaff1/bs-node-readline
Node readline bindings for BuckleScript
https://github.com/sscaff1/bs-node-readline
bucklescript bucklescript-bindings nodejs reasonml
Last synced: about 1 year ago
JSON representation
Node readline bindings for BuckleScript
- Host: GitHub
- URL: https://github.com/sscaff1/bs-node-readline
- Owner: sscaff1
- Created: 2018-07-05T13:45:32.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-02-08T01:55:17.000Z (over 6 years ago)
- Last Synced: 2025-04-09T19:09:29.328Z (about 1 year ago)
- Topics: bucklescript, bucklescript-bindings, nodejs, reasonml
- Language: Reason
- Homepage:
- Size: 44.9 KB
- Stars: 9
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bs-node-readline
Low level bindings for Node's readline
## Example
```reason
let options =
Readline.interfaceOptions(
~input=[%raw "process.stdin"],
~output=[%raw "process.stdout"],
(),
);
let readline = Readline.createInterface(options);
let yes = [%re "/yes|y/gi"];
let no = [%re "/no|n/gi"];
readline
|. Readline.question("Is ReasonML and BuckleScript awesome? ", answer => {
switch (answer) {
| a when Js.Re.test(a, yes) => print_endline("You know it!")
| a when Js.Re.test(a, no) =>
print_endline("You need to revaluate your answer")
| a =>
print_endline({j| I don't have a variant for your answer 😦: $a |j})
};
Readline.close(readline);
});
```
then you can run the compiled JS file with Node:

## Installation
```sh
npm i --save bs-node-readline
```
then add
Then add `bs-node-readline` to `bs-dependencies` in your `bsconfig.json`:
```js
{
...
"bs-dependencies": ["bs-node-readline"]
}
```
## Usage
See example in `example/example.re`. Follows the NodeJS API found here: https://nodejs.org/api/readline.html