Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zebp/channo
A channel library for Deno that provides Rust-like channels backed by async-cell.
https://github.com/zebp/channo
deno typescript
Last synced: 4 months ago
JSON representation
A channel library for Deno that provides Rust-like channels backed by async-cell.
- Host: GitHub
- URL: https://github.com/zebp/channo
- Owner: zebp
- License: unlicense
- Created: 2021-04-23T17:49:25.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-24T13:20:31.000Z (over 3 years ago)
- Last Synced: 2024-10-21T03:26:45.250Z (4 months ago)
- Topics: deno, typescript
- Language: TypeScript
- Homepage:
- Size: 20.5 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# channo
![npm](https://img.shields.io/npm/v/channo)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/zebp/channo/ci)
![NPM](https://img.shields.io/npm/l/channo)A channel library for Deno that provides Rust-like channels backed by
[async-cell](https://github.com/zebp/async-cell).## Example
```typescript
import { Channel } from "https://deno.land/x/channo/mod.ts";const printerChannel = new Channel();
async function listenForMessages() {
for await (const message of printerChannel.stream()) {
console.log(message);
}
}// Spawns a promise to listen for messages pushed to the channel.
listenForMessages();printerChannel.push("Hello, world!");
// Sleep for 100ms to allow time for the listener to process the messages.
await new Promise((resolve) => setTimeout(resolve, 100));
```