Skip to content

Latest commit

 

History

History
 
 

rstream-csp

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@thi.ng/rstream-csp

npm version npm downloads Mastodon Follow

Note

This is one of 199 standalone projects, maintained as part of the @thi.ng/umbrella monorepo and anti-framework.

🚀 Please help me to work full-time on these projects by sponsoring me on GitHub. Thank you! ❤️

About

Adapter bridge between async CSP channels and synchronous stream subscriptions/transformations of @thi.ng/rstream.

Status

STABLE - used in production

Search or submit any issues for this package

Related packages

  • @thi.ng/csp - Primitives & operators for Communicating Sequential Processes based on async/await and async iterables
  • @thi.ng/rstream - Reactive streams & subscription primitives for constructing dataflow graphs / pipelines

Installation

yarn add @thi.ng/rstream-csp

ESM import:

import * as rscsp from "@thi.ng/rstream-csp";

Browser ESM import:

<script type="module" src="https://esm.run/@thi.ng/rstream-csp"></script>

JSDelivr documentation

For Node.js REPL:

const rscsp = await import("@thi.ng/rstream-csp");

Package sizes (brotli'd, pre-treeshake): ESM: 235 bytes

Dependencies

API

Generated API docs

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

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
}

License

© 2018 - 2024 Karsten Schmidt // Apache License 2.0