# @makechtec/router-translator

> ## Usage ##

Latest version **1.0.2** (published 2022-07-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @makechtec/router-translator
pnpm add @makechtec/router-translator
yarn add @makechtec/router-translator
bun add @makechtec/router-translator
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-07-08 |
| First published | 2022-07-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | makechtec |
| Maintainers | makechtec |

## Links

- npm: https://www.npmjs.com/package/@makechtec/router-translator
- Repository: https://github.com/MakechTec/router-translator
- Homepage: https://github.com/MakechTec/router-translator#readme
- Issues: https://github.com/MakechTec/router-translator/issues
- npm.io page: https://npm.io/package/@makechtec/router-translator

## Recent versions

- 1.0.2 (latest) — 2022-07-08
- 1.0.1 — 2022-07-08

## README

# RouterTranslator #

## Usage ##

    import {RouterTranslator} from "@makechtec/router-translator";

    const translator = new RouterTranslator();

    const route = translator.extractInfo("/products/{id}/description", "/products/23/description");
    console.log(route.variables);

result:

    [
        {
            key: "id",
            value: "23"
        }
    ]

other example:

    const route = translator.extractInfo("/category/{category_id}/tag/{tag_id}", "/category/23/tag/45");
    console.log(route.variables);

result:

    [
        {
            key: "category_id",
            value: "23"
        },
        {
            key: "tag_id",
            value: "45"
        }
    ]

## buildUri ##

It perform the inverse function:

    const uri = translator.buildUri("/products/{id}/description", [ {key: "id", value: "23"} ]);
    console.log(uri);

result:

    "/products/23/description"

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