# helper-cache

> Easily register and get helper functions to be passed to any template engine or node.js application. Methods for both sync and async helpers.

Latest version **1.0.0** (published 2017-04-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install helper-cache
pnpm add helper-cache
yarn add helper-cache
bun add helper-cache
```

## 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-04-20 |
| First published | 2014-08-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert, doowb |
| Keywords | cache, compile, consolidate, engine, helper, helpers, lo-dash, lodash, render, template, templates |

## Links

- npm: https://www.npmjs.com/package/helper-cache
- Repository: https://github.com/helpers/helper-cache
- Issues: https://github.com/helpers/helper-cache/issues
- npm.io page: https://npm.io/package/helper-cache

## Dependencies (4)

- [get-value](https://npm.io/package/get-value.md) ^2.0.6
- [load-helpers](https://npm.io/package/load-helpers.md) ^1.0.1
- [define-property](https://npm.io/package/define-property.md) ^1.0.0
- [collection-visit](https://npm.io/package/collection-visit.md) ^1.0.0

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-04-20
- 0.5.1 (beta) — 2014-12-17
- 0.7.2 — 2015-08-21
- 0.7.1 — 2015-06-01
- 0.7.0 — 2015-04-23
- 0.6.0 — 2015-03-19
- 0.5.2 — 2015-02-17
- 0.4.4 — 2015-02-11
- 0.4.3 — 2015-02-10
- 0.5.0 — 2014-12-17
- 0.4.2 — 2014-11-11
- 0.4.1 — 2014-11-05
- 0.4.0 — 2014-11-05
- 0.3.0 — 2014-11-04
- 0.2.4 — 2014-10-31
- … 7 more at https://npm.io/package/helper-cache/versions

## README

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

> Easily register and get helper functions to be passed to any template engine or node.js application. Methods for both sync and async helpers.

## Table of Contents

- [Install](#install)
- [API](#api)
- [About](#about)

_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_

## Install

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

```sh
$ npm install --save helper-cache
```

Install with [yarn](https://yarnpkg.com):

```sh
$ yarn add helper-cache
```

## API

### [HelperCache](index.js#L19)

Create an instance of `HelperCache` with the given `options.`

**Params**

* `options` **{Object}**

**Example**

```js
var App = require('helper-cache');
var app = new App();
```

### [.addHelper](index.js#L47)

Register a helper.

**Params**

* `name` **{String}**
* `fn` **{Function}**
* `returns` **{Object}**: Retuns the instance of `HelperCache` for chaining.

**Example**

```js
app.helper('uppercase', function(str) {
  return str.toUpperCase();
});
```

### [.getHelper](index.js#L66)

Get a helper.

**Params**

* `name` **{String}**
* `fn` **{Function}**
* `returns` **{Object}**: Retuns the instance of `HelperCache` for chaining.

**Example**

```js
app.helper('uppercase', function(str) {
  return str.toUpperCase();
});
```

### [.helper](index.js#L84)

Register a sync template helper `fn` as `name`.

**Params**

* `name` **{String}**
* `fn` **{Function}**
* `returns` **{Object}**: Retuns the instance of `HelperCache` for chaining.

**Example**

```js
app.helper('uppercase', function(str) {
  return str.toUpperCase();
});
```

### [.helpers](index.js#L116)

Register multiple sync helpers at once.

**Params**

* `helpers` **{Object}**: Array of globs, file paths or key-value pair helper objects.
* `returns` **{Object}**: Retuns the instance of `HelperCache` for chaining.

**Example**

```js
app.helpers({
  foo: function() {},
  bar: function() {},
  baz: function() {}
});
```

### [.asyncHelper](index.js#L135)

Register an async template helper `fn` as `name`.

**Params**

* `name` **{String}**
* `fn` **{Function}**
* `returns` **{Object}**: Retuns the instance of `HelperCache` for chaining.

**Example**

```js
app.asyncHelper('uppercase', function(str) {
  return str.toUpperCase();
});
```

### [.asyncHelpers](index.js#L164)

Register multiple async helpers at once.

**Params**

* `helpers` **{Object}**: Array of globs, file paths or key-value pair helper objects.
* `returns` **{Object}**: Retuns the instance of `HelperCache` for chaining.

**Example**

```js
app.asyncHelpers({
  foo: function() {},
  bar: function() {},
  baz: function() {}
});
```

### [.group](index.js#L179)

Namespace a collection of sync helpers on the given `prop`.

**Params**

* `helpers` **{Object|Array}**: Object, array of objects, or glob patterns.

**Example**

```js
app.group('mdu', require('markdown-utils'));
// Usage: '<%= mdu.heading("My heading") %>'
```

### [.asyncGroup](index.js#L202)

Namespace a collection of async helpers on the given `prop`.

**Params**

* `helpers` **{Object|Array}**: Object, array of objects, or glob patterns.

**Example**

```js
app.asyncGroup('mdu', require('markdown-utils'));
// Usage: '<%= mdu.heading("My heading") %>'
```

### [.load](index.js#L234)

Load helpers.

**Params**

* `helpers` **{Object}**: Array of globs, file paths or key-value pair helper objects.
* `returns` **{Object}**: Retuns the instance of `HelperCache` for chaining.

**Example**

```js
app.load({
  foo: function() {},
  bar: function() {},
  baz: function() {}
});
```

## About

### Related projects

* [engine-cache](https://www.npmjs.com/package/engine-cache): express.js inspired template-engine manager. | [homepage](https://github.com/jonschlinkert/engine-cache "express.js inspired template-engine manager.")
* [handlebars-helpers](https://www.npmjs.com/package/handlebars-helpers): More than 130 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate… [more](https://github.com/helpers/handlebars-helpers) | [homepage](https://github.com/helpers/handlebars-helpers "More than 130 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate, Verb, Ghost, gulp-handlebars, grunt-handlebars, consolidate, or any node.js/Handlebars project.")
* [template-helpers](https://www.npmjs.com/package/template-helpers): Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or… [more](https://github.com/jonschlinkert/template-helpers) | [homepage](https://github.com/jonschlinkert/template-helpers "Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or any engine that supports helper functions.")
* [template](https://www.npmjs.com/package/template): Render templates using any engine. Supports, layouts, pages, partials and custom template types. Use template… [more](https://github.com/jonschlinkert/template) | [homepage](https://github.com/jonschlinkert/template "Render templates using any engine. Supports, layouts, pages, partials and custom template types. Use template helpers, middleware, routes, loaders, and lots more. Powers assemble, verb and other node.js apps.")

### 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.5.0, on April 20, 2017._

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