REPL (Read-eval-print loop) utilities.
Use Sender
to send message to REPL and Receiver
to receive message from
REPL.
import { Receiver, Sender } from "./mod.ts";
const proc = Deno.run({
cmd: ["ssh", "-tt", "localhost", "/bin/sh"],
stdin: "piped",
stdout: "piped",
});
const receiver = new Receiver(proc.stdout, {
pattern: /.*\$ $/,
});
const sender = new Sender(proc.stdin);
await receiver.recv();
await sender.send("ls -al\n");
const received = await receiver.recv();
await sender.send("exit\n");
await proc.status();
proc.close();
console.log("-".repeat(80));
console.log(received);
console.log("-".repeat(80));
import { Receiver, Sender } from "./mod.ts";
const username = "johntitor";
const password = "steinsgate";
const proc = Deno.run({
cmd: ["telnet", "localhost"],
stdin: "piped",
stdout: "piped",
});
const receiver = new Receiver(proc.stdout, {
pattern: /.* % /,
});
const sender = new Sender(proc.stdin);
await receiver.recv(/login: $/);
await sender.send(`${username}\n`);
await receiver.recv(/Password:$/);
await sender.send(`${password}\n`);
await receiver.recv();
await sender.send("ls -al\n");
const received = await receiver.recv();
await sender.send("exit\n");
await proc.status();
proc.close();
console.log("-".repeat(80));
console.log(received);
console.log("-".repeat(80));
Lint code like:
make lint
Format code like
make fmt
Check types like
make type-check
Run tests like:
make test
The code follows MIT license written in LICENSE. Contributors need to agree that any modifications sent in this repository follow the license.