sigsel.js
Selectable signals.
Inspired by Go's channels and Clojure's core.async
,
this library aims to make concurrent programming easier.
Since JS is single-threaded,
there can be no data races across synchronous calls.
This means we do not need channels and can just share variables.
However, we still want a mechanism for synchronizing asynchronous operations.
For that purpose, we use a signal
object.
Installation
npm i sigsel
Usage
Counter
import signal select from "sigsel"; let counter = 0; const click = ; const timeout = ; for ;; const timer = ; ; switch await case click: counter++; break; case timeout: counter--; break; ; ;