Show HN: ConcurrentML-style first-class synchronous operations for JavaScript
1–2 of 2 posts
Re: Show HN: ConcurrentML-style first-class synchronous operations for JavaScript
#2You can try the following code snippet on the https://playground.esm.sh/ if you're interested.
```typescript
import { Channel, select } from "https://esm.sh/sync-op";
async function main() {
const c1 = new Channel();
const c2 = new Channel();
const c3 = new Channel();
c1.send("hello").sync();
c2.send(1).sync();
c3.send(true).sync();
const r1 = await select(c1.receive(), c2.receive(), c3.receive());
alert(r1.unwrap());
const r2 = await select(c1.receive(), c2.receive(), c3.receive());
alert(r2.unwrap());
}
main();
```