This project is part of the @thi.ng/umbrella monorepo.
Adapter bridge between async CSP channels and synchronous stream subscriptions/transformations of @thi.ng/rstream.
STABLE - used in production
Search or submit any issues for this package
- @thi.ng/csp - ES6 promise based CSP primitives & operations
- @thi.ng/rstream - Reactive streams & subscription primitives for constructing dataflow graphs / pipelines
yarn add @thi.ng/rstream-csp
ES module import:
<script type="module" src="https://cdn.skypack.dev/@thi.ng/rstream-csp"></script>
For Node.js REPL:
# with flag only for < v16
node --experimental-repl-await
> const rstreamCsp = await import("@thi.ng/rstream-csp");
Package sizes (gzipped, pre-treeshake): ESM: 277 bytes
import * as rs from "@thi.ng/rstream";
import * as tx from "@thi.ng/transducers";
import { fromChannel } from "@thi.ng/rstream-csp";
import { Channel } from "@thi.ng/csp";
ch = new Channel();
stream = fromChannel(ch);
stream.subscribe(rs.trace("all"));
stream.subscribe(rs.trace("only evens"), tx.filter(tx.even));
ch.write(1);
// all 1
ch.write(2);
// all 2
// only evens 2
stream.subscribe(rs.trace("tentimes"), tx.map(x => x * 10));
// all 3
// tentimes 30
Karsten Schmidt
If this project contributes to an academic publication, please cite it as:
@misc{thing-rstream-csp,
title = "@thi.ng/rstream-csp",
author = "Karsten Schmidt",
note = "https://thi.ng/rstream-csp",
year = 2018
}
© 2018 - 2021 Karsten Schmidt // Apache Software License 2.0