# @koax/run

> Run a middleware stack.

Latest version **0.4.1** (published 2016-03-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @koax/run
pnpm add @koax/run
yarn add @koax/run
bun add @koax/run
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2016-03-03 |
| First published | 2016-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | koax |

## Links

- npm: https://www.npmjs.com/package/@koax/run
- Repository: https://github.com/koaxjs/run
- Homepage: https://github.com/koaxjs/run#readme
- Issues: https://github.com/koaxjs/run/issues
- npm.io page: https://npm.io/package/@koax/run

## Dependencies (7)

- [@f/map](https://npm.io/package/@f/map.md) ^1.5.3
- [@f/is-functor](https://npm.io/package/@f/is-functor.md) ^1.0.0
- [@f/to-promise](https://npm.io/package/@f/to-promise.md) ^1.1.2
- [@koax/compose](https://npm.io/package/@koax/compose.md) ^0.3.1
- [@f/is-iterator](https://npm.io/package/@f/is-iterator.md) ^1.0.1
- [@f/is-generator](https://npm.io/package/@f/is-generator.md) ^1.3.2
- [@f/is-undefined](https://npm.io/package/@f/is-undefined.md) ^1.1.1

## Recent versions

- 0.4.1 (latest) — 2016-03-03
- 0.3.1 — 2016-03-03
- 0.3.0 — 2016-02-25
- 0.2.2 — 2016-02-24
- 0.2.1 — 2016-02-24
- 0.2.0 — 2016-02-12
- 0.1.1 — 2016-02-06

## README

# run

[![Build status][travis-image]][travis-url]
[![Git tag][git-image]][git-url]
[![NPM version][npm-image]][npm-url]
[![Code style][standard-image]][standard-url]

Run a koax middleware stack.

This is the raw middleware stack runner. The basic principal of the runner is that values that are yielded in the middleware stack are dispatched back through the middleware stack to get resolved. yielded functors (arrays, generators, and iterators) aren't dispatched directly - instead the functors values are mapped, using predefined mapping functions, over the middleware stack.

## Installation

    $ npm install @koax/run

## Usage

```js
import run from '@koax/run'

let dispatch = run([
  function * (action, next) {
    if (action === 'foo') return 'bar'
    else if (action === 'qux') return yield 'foo'
    return next()
  },
  function * (action, next) {
    if (action === 'multi') return yield ['foo', 'qux']
    return next()
  }
])

dispatch('foo').then((res) => res) // => 'bar'
disaptch('qux').then((res) => res) // => 'bar'
disaptch('multi').then((res) => res) // => ['bar', 'bar']

```

## API

### run(middleware, ctx)

- `middleware` - koax middleware array
- `ctx` - ctx for middleware stack

**Returns:** dispatch function: `dispatch(action, next)`

## License

MIT

[travis-image]: https://img.shields.io/travis/koaxjs/run.svg?style=flat-square
[travis-url]: https://travis-ci.org/koaxjs/run
[git-image]: https://img.shields.io/github/tag/koaxjs/run.svg
[git-url]: https://github.com/koaxjs/run
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat
[standard-url]: https://github.com/feross/standard
[npm-image]: https://img.shields.io/npm/v/@koax/run.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@koax/run

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