Nondeterministic Palindrome Machine

    @thi.ng/rstream-dot
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.5 • Public • Published

    rstream-dot

    npm version npm downloads Twitter Follow

    This project is part of the @thi.ng/umbrella monorepo.

    About

    Graphviz DOT conversion of @thi.ng/rstream dataflow graph topologies.

    Status

    STABLE - used in production

    Search or submit any issues for this package

    Related packages

    Installation

    yarn add @thi.ng/rstream-dot

    ES module import:

    <script type="module" src="https://cdn.skypack.dev/@thi.ng/rstream-dot"></script>

    Skypack documentation

    For Node.js REPL:

    # with flag only for < v16
    node --experimental-repl-await
    
    > const rstreamDot = await import("@thi.ng/rstream-dot");
    

    Package sizes (gzipped, pre-treeshake): ESM: 835 bytes

    Dependencies

    Usage examples

    Several demos in this repo's /examples directory are using this package.

    A selection:

    Description Live demo Source
    Minimal rstream dataflow graph Demo Source

    API

    Generated API docs

    import * as rsd from "@thi.ng/rstream-dot";
    
    import * as rs from "@thi.ng/rstream";
    import * as tx from "@thi.ng/transducers";
    
    // create dummy dataflow
    a = rs.fromIterable([1,2,3]);
    b = rs.fromIterable([10, 20, 30]);
    a.transform(tx.map((x) => x * 10), "x10");
    rs.merge({src: [a, b]}).subscribe(rs.trace());
    
    // now capture the topology by walking the graph from its root(s)
    // and convert the result to GraphViz DOT format
    console.log(rsd.toDot(rsd.walk([a, b])));
    
    // digraph g {
    // rankdir=LR;
    // node[fontname=Inconsolata,fontsize=11,style=filled,fontcolor=white];
    // edge[fontname=Inconsolata,fontsize=11];
    // s0[label="iterable-0\n(Stream)", color=blue];
    // s1[label="x10", color=black];
    // s2[label="in-iterable-0", color=black];
    // s3[label="<noid>", color=gray];
    // s4[label="streammerge-0\n(StreamMerge)", color=red];
    // s5[label="sub-1", color=black];
    // s6[label="<noid>", color=gray];
    // s7[label="iterable-1\n(Stream)", color=blue];
    // s8[label="in-iterable-1", color=black];
    // s9[label="<noid>", color=gray];
    // s5 -> s6;
    // s4 -> s5;
    // s3 -> s4;
    // s2 -> s3;
    // s0 -> s1[label="xform"];
    // s0 -> s2;
    // s9 -> s4;
    // s8 -> s9;
    // s7 -> s8;
    // }

    Copy output to file graph.dot and then run:

    dot -Tsvg -o graph.svg graph.dot

    This will generate this diagram:

    graphviz output

    Authors

    Karsten Schmidt

    If this project contributes to an academic publication, please cite it as:

    @misc{thing-rstream-dot,
      title = "@thi.ng/rstream-dot",
      author = "Karsten Schmidt",
      note = "https://thi.ng/rstream-dot",
      year = 2018
    }

    License

    © 2018 - 2021 Karsten Schmidt // Apache Software License 2.0

    Install

    npm i @thi.ng/rstream-dot

    DownloadsWeekly Downloads

    10

    Version

    2.1.5

    License

    Apache-2.0

    Unpacked Size

    28.1 kB

    Total Files

    8

    Last publish

    Collaborators

    • thi.ng