# stream-router

> Easy router for routing streams

Latest version **0.1.0** (published 2012-08-14) · 0 weekly downloads

## Install

```sh
npm install stream-router
pnpm add stream-router
yarn add stream-router
bun add stream-router
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2012-08-14 |
| First published | 2012-08-09 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | Raynos |
| Maintainers | raynos |

## Links

- npm: https://www.npmjs.com/package/stream-router
- Repository: https://github.com/Raynos/stream-router
- Issues: https://github.com/Raynos/stream-router/issues
- npm.io page: https://npm.io/package/stream-router

## Dependencies (1)

- [routes](https://npm.io/package/routes.md) ~0.1.1

## Recent versions

- 0.1.0 (latest) — 2012-08-14
- 0.0.2 — 2012-08-10
- 0.0.1 — 2012-08-09

## README

# stream-router

Easy router for routing streams

## Example Server

``` js
var StreamRouter = require("stream-router")
    , streamRouter = StreamRouter()
    , MuxDemux = require("mux-demux")
    , net = require("net")

streamRouter.addRoute("/foo/:name", handleFoo)

net.createServer(handleTcp).listen(8642)

function handleTcp(con) {
    var mdm = MuxDemux({
        error: false
    })

    mdm.on("connection", streamRouter)

    con.pipe(mdm).pipe(con)
}

function handleFoo(stream, params) {
    stream.write(params.name)

    stream.on("data", console.log.bind(console, "server"))
}
```

## Example client

``` js
var MuxDemux = require("mux-demux")
    , net = require("net")
    , mdm = MuxDemux({
        error: false
    })
    , con = net.connect(8642)

con.pipe(mdm).pipe(con)

var foo = mdm.createStream("/foo/bar")

foo.on("data", console.log.bind(console, "client"))

foo.write("bar")
```

## Installation

`npm install stream-router`

## Contributors

 - Raynos

## MIT Licenced

  [1]: https://secure.travis-ci.org/Raynos/stream-router.png
  [2]: http://travis-ci.org/Raynos/stream-router

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