# @swim/dataflow

> Compiler from @swim/structure expressions to live-updated data models

Latest version **3.11.1** (published 2021-08-17) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @swim/dataflow
pnpm add @swim/dataflow
yarn add @swim/dataflow
bun add @swim/dataflow
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.11.1 |
| Published | 2021-08-17 |
| First published | 2019-02-18 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 655.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Chris Sachs |
| Maintainers | c9r |

## Links

- npm: https://www.npmjs.com/package/@swim/dataflow
- Repository: https://github.com/swimos/swim
- Homepage: https://github.com/swimos/swim/tree/master/swim-system-js/swim-core-js/@swim/dataflow
- Issues: https://github.com/swimos/swim/issues
- npm.io page: https://npm.io/package/@swim/dataflow

## Dependencies (5)

- [@swim/util](https://npm.io/package/@swim/util.md) 3.11.1
- [@swim/mapping](https://npm.io/package/@swim/mapping.md) 3.11.1
- [@swim/streamlet](https://npm.io/package/@swim/streamlet.md) 3.11.1
- [@swim/structure](https://npm.io/package/@swim/structure.md) 3.11.1
- [@swim/collections](https://npm.io/package/@swim/collections.md) 3.11.1

## Recent versions

- 3.11.1 (latest) — 2021-08-17
- 4.0.0-dev.20210927.3 (dev) — 2024-04-04
- 4.0.0-dev.20210927.2 — 2021-11-11
- 4.0.0-dev.20210927.1 — 2021-09-27
- 4.0.0-dev.20210927 — 2021-09-27
- 4.0.0-dev.20210923 — 2021-09-23
- 4.0.0-dev.20210920 — 2021-09-20
- 4.0.0-dev.20210826 — 2021-08-26
- 3.11.0 — 2021-08-15
- 3.11.0-dev.20210722 — 2021-07-22
- 3.11.0-dev.20210702 — 2021-07-03
- 3.11.0-dev.20210618 — 2021-06-18
- 3.11.0-dev.20210611.1 — 2021-06-11
- 3.11.0-dev.20210611 — 2021-06-11
- 3.11.0-dev.20210415 — 2021-04-15
- … 14 more at https://npm.io/package/@swim/dataflow/versions

## README

# @swim/dataflow

[![package](https://img.shields.io/npm/v/@swim/structure.svg)](https://www.npmjs.com/package/@swim/dataflow)
[![documentation](https://img.shields.io/badge/doc-TypeDoc-blue.svg)](https://docs.swimos.org/js/latest/modules/_swim_dataflow.html)
[![chat](https://img.shields.io/badge/chat-Gitter-green.svg)](https://gitter.im/swimos/community)

<a href="https://www.swimos.org"><img src="https://docs.swimos.org/readme/marlin-blue.svg" align="left"></a>

**@swim/dataflow** implements a compiler from
[**@swim/structure**](https://github.com/swimos/swim/tree/master/swim-system-js/swim-core-js/@swim/structure)
selectors, operators, and functions, to continuously updated data structures
driven by [**@swim/streamlet**](https://github.com/swimos/swim/tree/master/swim-system-js/swim-core-js/@swim/streamlet)
dataflow graphs.  **@swim/dataflow** turns dynamic data structures into living
documents.  **@swim/dataflow** is written in TypeScript, but can be used from
either TypeScript or JavaScript.  **@swim/dataflow** is part of the
[**@swim/core**](https://github.com/swimos/swim/tree/master/swim-system-js/swim-core-js/@swim/core) framework.

## Overview

A live updated data structure is represented as a `RecordScope`, which extends
`Record` from **@swim/structure**.  An ordinary `Record` can be recursively
compiled into a `RecordScope` by invoking the `RecordScope.from` factory method.
A compiled `RecordScope` has all of its nested expressions replaced by their
evaluated state.  But unlike evaluating a `Record` with an `Interpreter`, if a
member of a `RecordScope` changes, all expressions that transitively depend on
that member get flagged for recomputation, which occurs the next time
`recohereInput` gets invoked on the `RecordScope`.

The `Dataflow.compile` method can also be used to compile an arbitrary
**@swim/structure** expression into an `Outlet` that updates whenever
the state of any of its transitively dependend expressions changes.

## Installation

### npm

For an npm-managed project, `npm install @swim/dataflow` to
make it a dependency. TypeScript sources will be installed into
`node_modules/@swim/dataflow/main`. Transpiled JavaScript and TypeScript
definition files install into `node_modules/@swim/dataflow/lib/main`.
And a pre-built UMD script can be found in
`node_modules/@swim/dataflow/dist/main/swim-dataflow.js`.

### Browser

Browser applications can load `swim-core.js`, which comes bundled with the
**@swim/dataflow** library, directly from the SwimOS CDN.

```html
<!-- Development -->
<script src="https://cdn.swimos.org/js/latest/swim-core.js"></script>

<!-- Production -->
<script src="https://cdn.swimos.org/js/latest/swim-core.min.js"></script>
```

Alternatively, the standalone `swim-system.js` script may be loaded
from the SwimOS CDN, which bundles **@swim/dataflow** together with all other
[**@swim/system**](https://github.com/swimos/swim/tree/master/swim-system-js/@swim/system)
libraries.

```html
<!-- Development -->
<script src="https://cdn.swimos.org/js/latest/swim-system.js"></script>

<!-- Production -->
<script src="https://cdn.swimos.org/js/latest/swim-system.min.js"></script>
```

## Usage

### ES6/TypeScript

**@swim/dataflow** can be imported as an ES6 module from TypeScript and other
ES6-compatible environments.

```typescript
import * as dataflow from "@swim/dataflow";
```

### CommonJS/Node.js

**@swim/dataflow** can also be used as a CommonJS module in Node.js applications.

```javascript
var dataflow = require("@swim/dataflow");
```

### Browser

When loaded by a web browser, the `swim-core.js` script adds all
**@swim/dataflow** library exports to the global `swim` namespace.

The `swim-system.js` script also adds all **@swim/dataflow** library exports
to the global `swim` namespace, making it a drop-in replacement for
`swim-core.js` when additional **@swim/system** libraries are needed.

---
_Source: https://npm.io/package/@swim/dataflow · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
