# keymirror

> A simple utility for creating an object with values equal to its keys. Identical to react/lib/keyMirror

Latest version **0.1.1** (published 2014-12-21) · 0 weekly downloads

## Install

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

## Health

**Score 18/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2014-12-21 |
| First published | 2014-06-05 |
| Weekly downloads | 0 |
| TypeScript types | separate (@types/keymirror) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 378 |
| Author | Samuel Reed |
| Maintainers | strml |

## Links

- npm: https://www.npmjs.com/package/keymirror
- Repository: https://github.com/STRML/keyMirror
- Issues: https://github.com/STRML/keyMirror/issues
- npm.io page: https://npm.io/package/keymirror

## Recent versions

- 0.1.1 (latest) — 2014-12-21
- 0.1.0 — 2014-06-05

## README

KeyMirror
=========

Create an object with values equal to its key names.

I thought `react/lib/keyMirror` was useful and wanted to reuse it without any dependencies.

This is not my code, this is property of Facebook.

Usage
-----

`npm install keymirror`

```javascript
var keyMirror = require('keyMirror');
var COLORS = keyMirror({blue: null, red: null});
var myColor = COLORS.blue;
var isColorValid = !!COLORS[myColor];
```

The last line could not be performed if the values of the generated enum were
not equal to their keys.

Input:  `{key1: val1, key2: val2}`

Output: `{key1: key1, key2: key2}`

I sometimes use this with lodash - use the following upon your first use of lodash to mix it in:

```javascript
var _ = require('lodash');
_.mixin({keyMirror: require('keyMirror')});
// Can now be used as _.keyMirror(object)
```

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