# @f/middleware

> Utility for middleware composition.

Latest version **1.1.0** (published 2016-02-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @f/middleware
pnpm add @f/middleware
yarn add @f/middleware
bun add @f/middleware
```

## 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 | 1.1.0 |
| Published | 2016-02-02 |
| First published | 2015-12-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | f |

## Links

- npm: https://www.npmjs.com/package/@f/middleware
- Repository: https://github.com/micro-js/middleware
- Homepage: https://github.com/micro-js/middleware#readme
- Issues: https://github.com/micro-js/middleware/issues
- npm.io page: https://npm.io/package/@f/middleware

## Dependencies (1)

- [@f/slice](https://npm.io/package/@f/slice.md) ^1.1.1

## Recent versions

- 1.1.0 (latest) — 2016-02-02
- 1.0.0 — 2015-12-31
- 0.1.1 — 2015-12-31

## README

# middleware

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

Utility for middleware composition.

## Installation

    $ npm install @f/middleware

## Usage

```js
var middleware = require('@f/middleware')
var pipe = require('ramda').pipe

var powAdd = middleware(composePipe)
  .use(Math.pow)
  .use(function (arg) {
    return arg + 1
  })

powAdd(2, 4) // => 17

var powAddMultiply = powAdd.add(function (arg) {
  return arg * 2
})

powAddMultiply(2, 4) // => 34

function composePipe(stack) {
  return pipe.apply(null, stack)
}
```

## API

### middleware(compose, stack)

- `compose` - compose function with signature `compose(stack)`
- `stack` - array of middleware

**Returns:** A function representing the composition of the stack. The composed
function additionally has helper properties for manipulating the stack.

 - **.use(fn)**: adds `fn` to `stack`
 - **.add(fn)**: immutably add `fn` to `stack`
 - **.copy(fn)**: make copy of stack return new composed function
 - **.map(fn)**: map stack over `fn` and return new composed function

## License

MIT

[travis-image]: https://img.shields.io/travis/micro-js/middleware.svg?style=flat-square
[travis-url]: https://travis-ci.org/micro-js/middleware
[git-image]: https://img.shields.io/github/tag/micro-js/middleware.svg
[git-url]: https://github.com/micro-js/middleware
[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/@f/middleware.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@f/middleware

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