# uni-compose

> Compose multiple middlewares to one

Latest version **0.1.2** (published 2017-02-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install uni-compose
pnpm add uni-compose
yarn add uni-compose
bun add uni-compose
```

## 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.1.2 |
| Published | 2017-02-22 |
| First published | 2017-02-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tian Jian |
| Maintainers | kiliwalk, tianjianchn |
| Keywords | compose, middleware, midd |

## Links

- npm: https://www.npmjs.com/package/uni-compose
- Repository: https://github.com/tianjianchn/midd/tree/master/packages/uni-compose
- Issues: https://github.com/tianjianchn/midd/issues
- npm.io page: https://npm.io/package/uni-compose

## Recent versions

- 0.1.2 (latest) — 2017-02-22
- 0.1.1 — 2017-02-18

## README

# Compose use-* middlewares

Compose middlewares like `(req, resp, next)=>Promise` into one.  

## Examples
```js
const compose = require('uni-compose');
const stack = compose([
  async (req, resp, next)=>{
    await sleep(1);
    const result = await next()
    await sleep(1);
    return result;
  },
  (req, resp, next)=>{
    return new Promise((resolve, reject)=>{
      resolve(1)
    })
  }
])

//call the composed one
stack(req, resp).then(result=>assert.equal(result, 1));
```

## API
`compose(middlewares, options)`. options have:  
* `beforeRunMiddleware`: before invoking the specified middleware, check whether it can be run

## License

Licensed under MIT

Copyright (c) 2017 [Tian Jian](https://github.com/tianjianchn)

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