Skip to content

Concurrent ML style first-class synchronous operations for JavaScript

License

Notifications You must be signed in to change notification settings

dhcmrlchtdj/sync-op

Repository files navigation

sync-op

npm version

Concurrent ML style first-class synchronous operations for JavaScript.

Installation

Install the package using npm:

$ npm install sync-op

Or explore and experiment directly in your browser with StackBlitz.

Usage

Below is a quick example to get you started:

import { Channel, choose } from "sync-op"

const c1 = new Channel<string>()
const c2 = new Channel<number>()
const c3 = new Channel<boolean>()

c1.send("hello").sync()
c2.send(1).sync()
c3.receive().sync()

const op = choose(c1.receive(), c2.receive()) // Op<Option<string> | Option<number>>
await op.sync().unwrap() // maybe "hello" or 1

// `choose` can be nested
await choose(op, c3.send(true)).sync() // Option<string> | Option<number> | boolean

Dive into the documentation for the full API reference.

Resource

License

This library is licensed under LGPL-2.1.

The core of this library is derived from OCaml event.

About

Concurrent ML style first-class synchronous operations for JavaScript

Topics

Resources

License

Stars

Watchers

Forks