# keysmap

> Multiple keys mapping. Allow none-string keys.

Latest version **0.0.1** (published 2016-05-07) · MIT license · 0 weekly downloads

## Install

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

## 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.0.1 |
| Published | 2016-05-07 |
| First published | 2016-05-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ddchen |
| Maintainers | ddchen |
| Keywords | map, keys, multiple, none-string |

## Links

- npm: https://www.npmjs.com/package/keysmap
- Repository: https://github.com/LoveKino/keysmap
- Homepage: https://github.com/LoveKino/keysmap#readme
- Issues: https://github.com/LoveKino/keysmap/issues
- npm.io page: https://npm.io/package/keysmap

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 0.0.1 (latest) — 2016-05-07

## README

# keysmap

Multiple keys mapping. Allow none-string keys.

[![Build Status](https://travis-ci.org/LoveKino/keysmap.svg)](https://travis-ci.org/LoveKino/keysmap.svg)
[![Coverage Status](https://coveralls.io/repos/github/LoveKino/keysmap/badge.svg?branch=master)](https://coveralls.io/github/LoveKino/keysmap?branch=master)

## what is keysmap

It's map, but a group of multiple keys mapping one value.

eg:
```js
['a', 'b', 'c'] -> v0

['a'] -> v1

['d', 10, {}] -> v2
```

## install

`npm i keysmap --save`

## api

- var map = keysmap();

create map instance

- map.set (keys, value[, eq]) 

Keys object is an array. It's element could be anything.

Eq is function, used to compare two key.

`eq = (key1, key2) => {};// return true or false;`

- map.get (keys[, eq])

Keys object is an array. It's element could be anything.

Eq is function, used to compare two key.

- map.has (keys[, eq])

Keys object is an array. It's element could be anything.

Eq is function, used to compare two key.

- map.remove(keys[, eq])

Keys object is an array. It's element could be anything.

Eq is function, used to compare two key.

## examples

### multiple key

```js
var keysmap = require('keysmap')

var map = keysmap();

map.set(['a', 'b', 'c'], 4);

var ret = map.get(['a', 'b', 'c']);

console.log(ret); // 4
```

### empty key

```js
var keysmap = require('keysmap')

var map = keysmap();

map.set([], {a: 1});

var ret = map.get([]);

console.log(ret); // {a: 1}

```

### object keys

```js
var keysmap = require('keysmap')

var map = keysmap();

let obj = {};

map.set([1, obj], 20);

map.get([1, obj]); // 20
```

### custome eq function

```js
var keysmap = require('keysmap');
var jsoneq = require('cl-jsoneq');

var map = keysmap();

map.set(['a', {
    b: 30
}], 300);

map.get(['a', {
    b: 30
}]); // undefined

map.get(['a', {
    b: 30
}], jsoneq); // 300
```

### has and remove api

```js
var keysmap = require('keysmap');
var jsoneq = require('cl-jsoneq');

map.set(['a', 'b'], 20);
map.set([{
    k: 3
}], 20);

map.has(['a', 'b']); // true
map.has([{
    k: 3
}], jsoneq); // true


map.remove(['a', 'b']);
map.remove([{
    k: 3
}], jsoneq);
```

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