https://github.com/fixpoint/deno-replutil
🧰 REPL utilities
https://github.com/fixpoint/deno-replutil
deno node repl utilities
Last synced: about 2 months ago
JSON representation
🧰 REPL utilities
- Host: GitHub
- URL: https://github.com/fixpoint/deno-replutil
- Owner: fixpoint
- License: mit
- Created: 2022-03-07T09:58:08.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-26T00:05:54.000Z (about 2 years ago)
- Last Synced: 2025-05-11T09:48:00.308Z (about 1 year ago)
- Topics: deno, node, repl, utilities
- Language: TypeScript
- Homepage: https://deno.land/x/replutil
- Size: 11.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# replutil
[](https://www.npmjs.com/package/replutil)
[](https://deno.land/x/replutil)
[](https://doc.deno.land/https/deno.land/x/replutil/mod.ts)
[](https://github.com/fixpoint/deno-replutil/actions?query=workflow%3ATest)
[](https://badge.fury.io/js/replutil)
REPL (Read-eval-print loop) utilities.
## Usage
Use `Sender` to send message to REPL and `Receiver` to receive message from
REPL.
##### SSH
```typescript
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));
```
##### Telnet
```typescript
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));
```
## Development
Lint code like:
```text
make lint
```
Format code like
```text
make fmt
```
Check types like
```text
make type-check
```
Run tests like:
```text
make test
```
## License
The code follows MIT license written in [LICENSE](./LICENSE). Contributors need
to agree that any modifications sent in this repository follow the license.