https://github.com/jjeffcaii/deno-zeromq
Pure Deno bindings for ZeroMQ.
https://github.com/jjeffcaii/deno-zeromq
deno zeromq zmq
Last synced: 11 months ago
JSON representation
Pure Deno bindings for ZeroMQ.
- Host: GitHub
- URL: https://github.com/jjeffcaii/deno-zeromq
- Owner: jjeffcaii
- License: apache-2.0
- Created: 2021-01-14T02:50:57.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-24T15:26:32.000Z (over 5 years ago)
- Last Synced: 2025-07-25T23:30:10.919Z (11 months ago)
- Topics: deno, zeromq, zmq
- Language: TypeScript
- Homepage:
- Size: 45.9 KB
- Stars: 7
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# deno-zeromq

[](https://github.com/jjeffcaii/deno-zeromq/blob/master/LICENSE)
[](https://github.com/jjeffcaii/deno-zeromq/releases)
Deno bindings for ZeroMQ. (UNFINISHED! DO NOT USE IT!!!)
## Examples
### Request/Reply
> Reply
```typescript
import * as zmq from "https://deno.land/x/zeromq/mod.ts";
const socket = zmq.Reply();
await socket.bind("tcp://127.0.0.1:5555");
for await (const [req] of socket) {
console.log(`Receive: [${new TextDecoder().decode(req as Uint8Array)}]`);
socket.send("World");
}
```
> Request
```typescript
import * as zmq from "https://deno.land/x/zeromq/mod.ts";
const socket = zmq.Request();
await socket.connect("tcp://127.0.0.1:5555");
await socket.send("Hello");
const [res] = await socket.receive();
console.log(`Receive: ${new TextDecoder().decode(res as Uint8Array)}`);
```
### Pub/Sub
> Publish
```typescript
import * as zmq from "https://deno.land/x/zeromq/mod.ts";
const socket = zmq.Publish();
await socket.bind("tcp://127.0.0.1:5555");
while (true) {
await socket.send("kitty cats", `meow!`);
await new Promise((resolve) => setTimeout(resolve, 500));
}
```
> Subscribe
```typescript
import * as zmq from "https://deno.land/x/zeromq/mod.ts";
const sock = zmq.Subscribe();
await sock.connect("tcp://127.0.0.1:5555");
await sock.subscribe("kitty cats");
const dec = new TextDecoder();
for await (const [topic, msg] of sock) {
console.log(
`topic=${dec.decode(topic as Uint8Array)}, msg=${
dec.decode(msg as Uint8Array)
}`,
);
}
```
## TODO
- [x] Basic ZMTP Framing
- [ ] ZMTP-NULL
- [ ] ZMTP-PLAIN
- [ ] ZMTP-CURVE
- [x] REQ/REP
- [x] PUB/SUB
- [ ] PUSH/PULL
- [ ] ...