# map-cache

> Basic cache object for storing key-value pairs.

Latest version **0.2.2** (published 2016-05-10) · MIT license · 0 weekly downloads

## Install

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

## 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.2.2 |
| Published | 2016-05-10 |
| First published | 2015-02-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert |
| Keywords | cache, get, has, object, set, storage, store |

## Links

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

## 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

- 0.2.2 (latest) — 2016-05-10
- 0.2.1 — 2016-04-11
- 0.2.0 — 2015-06-23
- 0.1.1 — 2015-03-18
- 0.1.0 — 2015-02-25

## README

# map-cache [![NPM version](https://img.shields.io/npm/v/map-cache.svg?style=flat)](https://www.npmjs.com/package/map-cache) [![NPM downloads](https://img.shields.io/npm/dm/map-cache.svg?style=flat)](https://npmjs.org/package/map-cache) [![Build Status](https://img.shields.io/travis/jonschlinkert/map-cache.svg?style=flat)](https://travis-ci.org/jonschlinkert/map-cache)

Basic cache object for storing key-value pairs.

## Install

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

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

Based on MapCache in Lo-dash v3.0. [MIT License](https://github.com/lodash/lodash/blob/master/LICENSE.txt)

## Usage

```js
var MapCache = require('map-cache');
var mapCache = new MapCache();
```

## API

### [MapCache](index.js#L28)

Creates a cache object to store key/value pairs.

**Example**

```js
var cache = new MapCache();
```

### [.set](index.js#L45)

Adds `value` to `key` on the cache.

**Params**

* `key` **{String}**: The key of the value to cache.
* `value` **{any}**: The value to cache.
* `returns` **{Object}**: Returns the `Cache` object for chaining.

**Example**

```js
cache.set('foo', 'bar');
```

### [.get](index.js#L65)

Gets the cached value for `key`.

**Params**

* `key` **{String}**: The key of the value to get.
* `returns` **{any}**: Returns the cached value.

**Example**

```js
cache.get('foo');
//=> 'bar'
```

### [.has](index.js#L82)

Checks if a cached value for `key` exists.

**Params**

* `key` **{String}**: The key of the entry to check.
* `returns` **{Boolean}**: Returns `true` if an entry for `key` exists, else `false`.

**Example**

```js
cache.has('foo');
//=> true
```

### [.del](index.js#L98)

Removes `key` and its value from the cache.

**Params**

* `key` **{String}**: The key of the value to remove.
* `returns` **{Boolean}**: Returns `true` if the entry was removed successfully, else `false`.

**Example**

```js
cache.del('foo');
```

## Related projects

You might also be interested in these projects:

* [cache-base](https://www.npmjs.com/package/cache-base): Basic object cache with `get`, `set`, `del`, and `has` methods for node.js/javascript projects. | [homepage](https://github.com/jonschlinkert/cache-base)
* [config-cache](https://www.npmjs.com/package/config-cache): General purpose JavaScript object storage methods. | [homepage](https://github.com/jonschlinkert/config-cache)
* [option-cache](https://www.npmjs.com/package/option-cache): Simple API for managing options in JavaScript applications. | [homepage](https://github.com/jonschlinkert/option-cache)

## Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/map-cache/issues/new).

## Building docs

Generate readme and API documentation with [verb](https://github.com/verbose/verb):

```sh
$ npm install verb && npm run docs
```

Or, if [verb](https://github.com/verbose/verb) is installed globally:

```sh
$ verb
```

## Running tests

Install dev dependencies:

```sh
$ npm install -d && npm test
```

## Author

**Jon Schlinkert**

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

## License

Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/jonschlinkert/map-cache/blob/master/LICENSE).

***

_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on May 10, 2016._

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