# mesh

> Data flow library for WHATWG streams

Latest version **7.0.3** (published 2017-06-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install mesh
pnpm add mesh
yarn add mesh
bun add mesh
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 7.0.3 |
| Published | 2017-06-14 |
| First published | 2012-02-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 997 |
| Maintainers | architectd, crcn |

## Links

- npm: https://www.npmjs.com/package/mesh
- Repository: https://github.com/crcn/mesh.js
- Homepage: https://github.com/crcn/mesh.js#readme
- Issues: https://github.com/crcn/mesh.js/issues
- npm.io page: https://npm.io/package/mesh

## Recent versions

- 7.0.3 (latest) — 2017-06-14
- 8.0.15 (alpha) — 2017-07-28
- 5.0.19 (trunk) — 2015-10-26
- 8.0.14 — 2017-07-26
- 8.0.13 — 2017-07-26
- 8.0.12 — 2017-07-26
- 8.0.11 — 2017-07-24
- 8.0.10 — 2017-07-24
- 8.0.9 — 2017-07-24
- 8.0.8 — 2017-07-24
- 8.0.7 — 2017-07-24
- 8.0.4 — 2017-07-12
- 8.0.3 — 2017-07-12
- 8.0.2 — 2017-07-11
- 8.0.0 — 2017-07-10
- … 128 more at https://npm.io/package/mesh/versions

## README

##  ⚠️ This library is no longer maintained, and should not be used in production applications. 

[![Build Status](https://travis-ci.org/crcn/mesh.js.svg)](https://travis-ci.org/crcn/mesh.js) [![Coverage Status](https://coveralls.io/repos/crcn/mesh.js/badge.svg?branch=master&service=github)](https://coveralls.io/github/crcn/mesh.js?branch=master) [![Join the chat at https://gitter.im/crcn/mesh.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/crcn/mesh.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)


<p align="center">
  <img width="300px" style="margin:0px auto" src="https://cloud.githubusercontent.com/assets/757408/11253633/a825c1c8-8df1-11e5-972d-e9256d9b2e13.png">
</p>

Mesh is a utility library for [async iterable iterators](https://github.com/tc39/proposal-async-iteration). 

#### Motivation

This library was originally created to handle complex data flows, and unify how applications communicate internally and externally. It also serves as a _single_ channel for _all_ communication which makes it more easy to control & reason about how your application is passing around data asynchronously. 

Mesh provides a set of higher order functions that you can use to build your data flows out. Here's an example of that:

```typescript
import { when, wrapAsyncIterableIterator, fallback } from "mesh";
import { 
  DS_FIND, 
  DS_INSERT, 
  DS_REMOVE, 
  DS_UPDATE, 
  dataStore, 
  DSFindMessage,
  whenCollection,
  DSInsertMessage,
  DSRemoveMessage,
  DSUpdateMessage,
} from "mesh-ds";

const insertTodoItem = (message: DSInsertMessage) => (
  wrapAsnycIterableIterator(fetch('/api/todos', {
    method: 'POST',
    body: message.data
  }))
);

const insert = fallback(
  whenCollection('todos', insertTodoItem),

  // more collections below
  // whenCollection('users', insertUser),
  // whenCollection('items', insertItem),
);

const dsDispatch = dataStore({
  [DS_INSERT] : insert,

  // other operations - similar code to insert
  //[DS_REMOVE] : remove,
  //[DS_UPDATE] : update,
  //[DS_FIND]   : find
});
```

<!-- TODO - rollback,  -->


#### Installation

[NPM](https://www.npmjs.com/): `npm install mesh` <br />
[Bower](http://bower.io/): `bower install mesh`

#### Resources

- Documentation
  - [Core API](https://github.com/crcn/mesh.js/tree/master/packages/mesh/docs/api.md)
- [Examples](./examples)
- Modules
    - Data Store Adapters
      - [in-memory data store bus](./packages/mesh-memory-ds-bus)
      - [mongodb bus](./packages/mesh-mongo-ds-bus)
      - [lokijs bus](./packages/mesh-loki-ds-bus) - lokijs in-memory adapter
      - [local storate bus](./packages/mesh-local-storage-ds-bus) - local storage DS adapter
      - [array bus](./packages/mesh-collection-bus) - persist DS operations to an array collection
    - Realtime Protocol Adapters
      - [socket.io bus](./packages/mesh-socket-io-bus)
      - [webrtc bus](./packages/mesh-webrtc-bus)
    - Other Adapters
      - [http bus](./packages/mesh-http-bus) - HTTP request bus
    - Other Busses
      - [upsert ds action](./packages/mesh-webrtc-bus) - adds upsert (insert/update) action for DS busses
      - [tailable bus](./packages/mesh-tailable-bus) - adds ability to listen for all executed operations
      - [remote protocol adapter bus](./packages/mesh-remote-bus) - adapter bus for any realtime protocol
- Discuss
  - [Google group](https://groups.google.com/forum/#!forum/meshjs)
  - [Gitter chat](https://gitter.im/crcn/mesh.js)
- Companies using Mesh
  - [HelloSign](https://www.hellosign.com/)
- Articles
  - [Why re-write code when you can strangle it?](http://blog.hellosign.com/why-rewrite-your-code-when-you-can-strangle-it/)

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