# middleware-utils

> Utils for Template middleware.

Latest version **1.0.0** (published 2017-07-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install middleware-utils
pnpm add middleware-utils
yarn add middleware-utils
bun add middleware-utils
```

## 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.0.0 |
| Published | 2017-07-16 |
| First published | 2015-04-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert |
| Keywords | assemble, assembleutils, async, generate, middleware, route, routes, template, templateutils, update, utils, verb, verbutils |

## Links

- npm: https://www.npmjs.com/package/middleware-utils
- Repository: https://github.com/jonschlinkert/middleware-utils
- Issues: https://github.com/jonschlinkert/middleware-utils/issues
- npm.io page: https://npm.io/package/middleware-utils

## Dependencies (2)

- [async-each](https://npm.io/package/async-each.md) ^1.0.1
- [async-array-reduce](https://npm.io/package/async-array-reduce.md) ^0.2.1

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-07-16
- 0.3.1 — 2016-08-02
- 0.3.0 — 2016-08-02
- 0.2.0 — 2016-06-21
- 0.1.4 — 2015-06-14
- 0.1.3 — 2015-06-13
- 0.1.2 — 2015-04-30
- 0.1.1 — 2015-04-29
- 0.1.0 — 2015-04-29

## README

# middleware-utils [![NPM version](https://img.shields.io/npm/v/middleware-utils.svg?style=flat)](https://www.npmjs.com/package/middleware-utils) [![NPM monthly downloads](https://img.shields.io/npm/dm/middleware-utils.svg?style=flat)](https://npmjs.org/package/middleware-utils) [![NPM total downloads](https://img.shields.io/npm/dt/middleware-utils.svg?style=flat)](https://npmjs.org/package/middleware-utils) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/middleware-utils.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/middleware-utils)

> Utils for Template middleware.

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save middleware-utils
```

## Usage

```js
var utils = require('middleware-utils');
```

## API

### [.series](index.js#L36)

Run one or more middleware in series.

**Params**

* `fns` **{Array|Function}**: Function or array of middleware functions

**Example**

```js
var utils = require('middleware-utils');
app.preRender(/\.hbs$/, utils.series([
  fn('foo'),
  fn('bar'),
  fn('baz')
]));

function fn(name) {
  return function(file, next) {
    console.log(name);
    next();
  };
}
```

### [.parallel](index.js#L72)

Run one or more middleware in parallel.

**Params**

* `fns` **{Array|Function}**: Function or array of middleware functions

**Example**

```js
var utils = require('middleware-utils');
app.preRender(/\.hbs$/, utils.parallel([
  fn('foo'),
  fn('bar'),
  fn('baz')
]));

function fn(name) {
  return function(file, next) {
    console.log(name);
    next();
  };
}
```

### [.error](index.js#L100)

Format errors for the middleware `done` function. Takes the name of the middleware method being handled.

**Params**

* `method` **{String}**: The middleware method name

**Example**

```js
app.postRender(/./, function(view, next) {
  // do stuff to view
  next();
}, utils.error('postRender'));
```

### [.handleError](index.js#L132)

Format errors for the `app.handle()` method.

**Params**

* `view` **{Object}**: View object
* `method` **{String}**: The middleware method name
* `next` **{String}**: Callback function

**Example**

```js
app.handle('onFoo', view, utils.handleError(view, 'onFoo'));
```

### [.delims](index.js#L151)

Returns a function for escaping and unescaping erb-style template delimiters.

**Params**

* `options` **{Object}**

**Example**

```js
var delims = mu.delims();
app.preRender(/\.tmpl$/, delims.escape());
app.postRender(/\.tmpl$/, delims.unescape());
```

## About

### Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

### Building docs

_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_

To generate the readme, run the following command:

```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```

### Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

```sh
$ npm install && npm test
```

### Author

**Jon Schlinkert**

* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)

### License

Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 16, 2017._

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