# recursive-remap

> Rename object's keys from specified map.

Latest version **1.0.1** (published 2022-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install recursive-remap
pnpm add recursive-remap
yarn add recursive-remap
bun add recursive-remap
```

## 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 | 2022-10-24 |
| First published | 2022-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kritish Dhaubanjar |
| Maintainers | kritish-dhaubanjar |
| Keywords | remap, remap keys, remap object |

## Links

- npm: https://www.npmjs.com/package/recursive-remap
- Repository: https://github.com/kritish-dhaubanjar/recursive-remap
- Homepage: https://github.com/kritish-dhaubanjar/recursive-remap#readme
- Issues: https://github.com/kritish-dhaubanjar/recursive-remap/issues
- npm.io page: https://npm.io/package/recursive-remap

## Recent versions

- 1.0.1 (latest) — 2022-10-24
- 1.0.0 — 2022-10-24

## README

## Description
Rename object's keys from specified map.

## Installation
```shell
npm install recursive-remap 
```

## Usage #1

```javascript
const recursiveRemap  = require("recursive-remap");

const object = {
  a: {
    b: {
      c: 1,
      d: {
        e: 2
      }
    }
  }
}

const MAP = {
  a: "A",
  A: {
    b: "B",
    B: [
      { c: "C" },
      {
        d: {
          e: "E"
        }
      }
    ]
  }
}

const remappedObject = recursiveRemap(object, MAP)

console.dir(remappedObject, { depth: null })
```

Output:
```javascript
{
  A: { B: { d: { E: 2 }, C: 1 } }
}
```

## Usage #2

```javascript
const recursiveRemap  = require("recursive-remap");

const object = {
  a: {
    b: {
      c: 1,
      d: {
        e: 3,
        f: {
          g: 4
        }
      }
    },
    h: [
      {
        i: { m: 5 },
        j: { n: 6 },
        k: 7,
        l: 8
      },
    ]
  }
}

const MAP_1 = {
  a: "A",
  A: {
    b: "B",
    B: [
      { c: "C" },
      { d: "D" },
      {
        D: {
          e: "E",
          f: "F",
          F: {
            g: "G"
          }
        }
      },
    ],
    h: "H"
  },
}

const MAP_2 = {
  i: "I",
  j: "J",
  l: "L",
  I: { m: "M" },
  J: { n: "N" }
}

console.dir(object, { depth: null })

const remappedObject = recursiveRemap(object, MAP_1)
remappedObject.A.H = remappedObject.A.H.map((t) => recursiveRemap(t, MAP_2))

console.dir(remappedObject, { depth: null })
```

Output:
```javascript
{
  a: {
    b: { c: 1, d: { e: 3, f: { g: 4 } } },
    h: [ { i: { m: 5 }, j: { n: 6 }, k: 7, l: 8 } ]
  }
}
{
  A: {
    B: { C: 1, D: { E: 3, F: { G: 4 } } },
    H: [ { k: 7, I: { M: 5 }, J: { N: 6 }, L: 8 } ]
  }
}
```

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