ArchStream

Modular stream for domain and data oriented program architecture design.
API
dist/arch-stream.d.ts
Install
$ npm i arch-stream
$ bower install arch-stream
Usage
Message and Thenable data cannot send directly.
Modular stream
import { A as ArchStream } from 'arch-stream';
const add1 =
ArchStream<number>()
.trans(n => ++n)
.export(),
add2 =
ArchStream<number>()
.import(add1)
.import(add1)
.export(),
add3 =
ArchStream<number>()
.import(add1)
.import(add2)
.export();
ArchStream<number>()
.import(add1)
.import(add2)
.import(add3)
.export()
.read(n => console.log(n))
.write(0)
.write(9);
Thenable
import { A as ArchStream } from 'arch-stream';
ArchStream<any>()
.trans(n => new Promise(resolve => setTimeout(_ => resolve(n / 10), 100 - n)))
.export()
.read(n => console.log(n))
.write(10)
.write(20);
Proxy
Unable use on TypeScript because untyped.
State
import { A as ArchStream } from 'arch-stream';
ArchStream<number>()
.proxy(A.Proxy.State({index: [0, 1], indexer: n => n % 2, void: false}))
.trans(n => n, n => -n)
.export()
.read(n => console.log(n))
.write(1)
.write(2);
Custom
Call order constraints (Type constraint)
Possible
- trans > trans
- trans > export
- trans > proxy
- proxy > trans
- proxy > proxy
- import > import
- import > export
- export > read
- read > write
Impossible
- trans > import
- trans > read
- export > trans
- export > import
- import > trans
- import > read
- read > read
- write > read
Browser
- Chrome
- Firefox
- IE9+
- Phantomjs
Test
$ npm i && grunt install
$ grunt test
$ grunt perf