{"by":"joeycumines","descendants":73,"id":38156519,"kids":[38158109,38158784,38158490,38165847,38159858,38162164,38164109,38159885,38160942,38159038,38161923,38158455],"score":60,"text":"Hey HN,<p>I’m sharing ts-chan, an NPM package providing Go-like concurrency primitives, including channels and select statements, for TypeScript and JavaScript, supporting Node.js, Deno, Bun, and browsers.<p>This is something I&#x27;ve built to make implementing Go-style &quot;control loops&quot; feasible in JavaScript, but there are many possible applications.<p>Highlights:<p>- Features a FIFO processing Chan class and versatile Select class for concurrency control.\n- Supports buffered channel and channel close semantics very close to Go&#x27;s.\n- TypeScript-first implementation.\n- Defines a simple &quot;channel protocol&quot; inspired by JavaScript&#x27;s iteration protocols, that&#x27;s used by `Select`, and implemented by `Chan`.\n- Makes an effort to mitigate cycles caused by the behavior of JavaScript&#x27;s microtask queue.\n- Ongoing project with active iteration for a production-ready module (pre-v1, so the API isn&#x27;t guaranteed to be stable, but the implementation itself is).<p>NPM: ts-chan\nGitHub: github.com&#x2F;joeycumines&#x2F;ts-chan<p>Thanks!","time":1699224632,"title":"Show HN: Ts-Chan – Go-Like Concurrency Primitives for TypeScript/JavaScript","type":"story","url":"https://github.com/joeycumines/ts-chan"}