# @reasonx7/mirror-keys

> One more key-mirror like utility.

Latest version **1.0.1** (published 2018-09-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install @reasonx7/mirror-keys
pnpm add @reasonx7/mirror-keys
yarn add @reasonx7/mirror-keys
bun add @reasonx7/mirror-keys
```

## 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.1 |
| Published | 2018-09-12 |
| First published | 2018-09-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ReasonX7 |
| Maintainers | reasonx7 |
| Keywords | key, mirror |

## Links

- npm: https://www.npmjs.com/package/@reasonx7/mirror-keys
- Repository: https://github.com/ReasonX7/mirror-keys
- Homepage: https://github.com/ReasonX7/mirror-keys#readme
- Issues: https://github.com/ReasonX7/mirror-keys/issues
- npm.io page: https://npm.io/package/@reasonx7/mirror-keys

## Recent versions

- 1.0.1 (latest) — 2018-09-12
- 1.0.0 — 2018-09-12

## README

# mirror-keys

A flexible way to mirror object keys.

## Installation

```bash
npm i mirror-keys
```

## Usage

### Importing

Node modules:
```js
const mk = require('mirror-keys');
```

ES6 modules:
```js
import mk from 'mirror-keys';
```

### Scenarios

#### No options

Input:
```js
const output = mk({
  a: 'a',
  b: null,
  nested: {
    x: 'x',
    y: null,
  },
});
```
Output:
```js
{
  a: 'a',
  b: 'b',
  nested: {
    x: 'x',
    y: 'nested.y',
  },
}
```

#### Prefix

Input:
```js
const output = mk({
  a: 'a',
  b: null,
  nested: {
    x: 'x',
    y: null,
  },
}, 'PREFIX::');
```
Output:
```js
{
  a: 'a',
  b: 'PREFIX::b',
  nested: {
    x: 'x',
    y: 'PREFIX::nested.y',
  },
}
```

#### Custom

Input:
```js
const output = mk({
  a: 'a',
  b: null,
  nested: {
    x: 'x',
    y: null,
  },
}, mk.flow(mk.joinPath, key => key.replace('.', '-')));
```
Output:
```js
{
  a: 'a',
  b: 'b',
  nested: {
    x: 'x',
    y: 'nested-y',
  },
}
```

Available modifiers:

- `mk.flow(...funcs): string` - combines modifiers into one flow.
- `mk.upper(key: string): string` - converts key to `UPPERCASE`.
- `mk.prefix(prefix: string): function` - creates a function that adds a prefix to the key.
- `mk.snake(prefix: string): string` - converts key to `snake_case`.
- `mk.joinPath(key: string, path: string): string` - adds a path to the nested key.

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