# namedtuplemap

> A Map which accepts a named tuple of objects as a key

Latest version **1.0.0** (published 2016-12-21) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install namedtuplemap
pnpm add namedtuplemap
yarn add namedtuplemap
bun add namedtuplemap
```

## 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 | 2016-12-21 |
| First published | 2016-12-21 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | @louis_remi |
| Maintainers | louisremi |
| Keywords | cache, map, tuple |

## Links

- npm: https://www.npmjs.com/package/namedtuplemap
- npm.io page: https://npm.io/package/namedtuplemap

## 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) — 2016-12-21

## README

NamedTupleMap [![npm version](https://badge.fury.io/js/namedtuplemap.svg)](https://badge.fury.io/js/namedtuplemap) [![Build Status](https://travis-ci.org/memoize-immutable/NamedTupleMap.svg?branch=master)](https://travis-ci.org/memoize-immutable/NamedTupleMap) [![Dependency Status](https://david-dm.org/memoize-immutable/NamedTupleMap.svg)](https://david-dm.org/memoize-immutable/NamedTupleMap) [![Coverage Status](https://coveralls.io/repos/github/memoize-immutable/NamedTupleMap/badge.svg?branch=master)](https://coveralls.io/github/memoize-immutable/NamedTupleMap?branch=master)
=============

A Map which accepts a named tuple as a key.
This lib is one of the several possible cache for [memoize-immutable](/louisremi/memoize-immutable),
but it can suit other use-cases as it implements a usual Map API.

## Install

`npm install --save NamedTupleMap`

This lib has no dependency, but requires a native implementation of Map.

## Usage

```js
var NamedTupleMap = require('NamedTupleMap');

// When the `limit` option is set, NamedTupleMap turns into an LRU cache.
// Clearing the map every X seconds can also be an acceptable strategy sometimes.
var cache = new NamedTupleMap({ limit: 10000 });

var keyPart1 = {};
var keyPart2 = 'yolo';
var keyPart3 = [];
var value = {any: 'thing'};

// Note that following named tuples are wrapped in new objects that are !==
// (otherwise a Map would have been enough).
cache.set({
  oh: keyPart1,
  my: keyPart2,
  goodness: keyPart3
}, value);

cache.has({
  oh: keyPart1,
  my: keyPart2,
  goodness: keyPart3
}) === true;
cache.get({
  oh: keyPart1,
  my: keyPart2,
  goodness: keyPart3
}) === value;
```

## Author

[@louis_remi](https://twitter.com/louis_remi)

## License

MPL-2.0

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