@thi.ng/rstream-csp
Version:
@thi.ng/csp bridge module for @thi.ng/rstream
123 lines (86 loc) • 3.48 kB
Markdown
<!-- This file is generated - DO NOT EDIT! -->
<!-- Please see: https://github.com/thi-ng/umbrella/blob/develop/CONTRIBUTING.md#changes-to-readme-files -->
# 
[](https://www.npmjs.com/package/@thi.ng/rstream-csp)

[](https://mastodon.thi.ng/@toxi)
> [!NOTE]
> This is one of 210 standalone projects, maintained as part
> of the [.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
> and anti-framework.
>
> 🚀 Please help me to work full-time on these projects by [sponsoring me on
> GitHub](https://github.com/sponsors/postspectacular). Thank you! ❤️
- [About](#about)
- [Status](#status)
- [Related packages](#related-packages)
- [Installation](#installation)
- [Dependencies](#dependencies)
- [API](#api)
- [Authors](#authors)
- [License](#license)
## About
Adapter bridge between async [CSP
channels](https://github.com/thi-ng/umbrella/tree/develop/packages/csp)
and synchronous stream subscriptions/transformations of
[.ng/rstream](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream).
## Status
**STABLE** - used in production
[Search or submit any issues for this package](https://github.com/thi-ng/umbrella/issues?q=%5Brstream-csp%5D+in%3Atitle)
## Related packages
- [.ng/csp](https://github.com/thi-ng/umbrella/tree/develop/packages/csp) - Primitives & operators for Communicating Sequential Processes based on async/await and async iterables
- [.ng/rstream](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream) - Reactive streams & subscription primitives for constructing dataflow graphs / pipelines
## Installation
```bash
yarn add .ng/rstream-csp
```
ESM import:
```ts
import * as rscsp from "@thi.ng/rstream-csp";
```
Browser ESM import:
```html
<script type="module" src="https://esm.run/@thi.ng/rstream-csp"></script>
```
[JSDelivr documentation](https://www.jsdelivr.com/)
For Node.js REPL:
```js
const rscsp = await import("@thi.ng/rstream-csp");
```
Package sizes (brotli'd, pre-treeshake): ESM: 235 bytes
## Dependencies
- [.ng/csp](https://github.com/thi-ng/umbrella/tree/develop/packages/csp)
- [.ng/rstream](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream)
## API
[Generated API docs](https://docs.thi.ng/umbrella/rstream-csp/)
```ts
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
```
## Authors
- [Karsten Schmidt](https://thi.ng)
If this project contributes to an academic publication, please cite it as:
```bibtex
{thing-rstream-csp,
title = "@thi.ng/rstream-csp",
author = "Karsten Schmidt",
note = "https://thi.ng/rstream-csp",
year = 2018
}
```
## License
© 2018 - 2025 Karsten Schmidt // Apache License 2.0