# cnp-decoder

> A function that decodes a romanian CNP and returns a object containing informations about the person it belongs to

Latest version **1.2.0** (published 2022-09-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install cnp-decoder
pnpm add cnp-decoder
yarn add cnp-decoder
bun add cnp-decoder
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2022-09-11 |
| First published | 2022-09-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andrei Muntean |
| Maintainers | andreimuntean |
| Keywords | cnp, romania, cnp decoder |

## Links

- npm: https://www.npmjs.com/package/cnp-decoder
- Repository: https://github.com/andreimuntean1/cnp-decoder
- Homepage: https://github.com/andreimuntean1/cnp-decoder#readme
- Issues: https://github.com/andreimuntean1/cnp-decoder/issues
- npm.io page: https://npm.io/package/cnp-decoder

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads
- [datasets-fi-postalcodes](https://npm.io/package/datasets-fi-postalcodes.md) — 1.1K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2022-09-11
- 1.1.0 — 2022-09-11
- 1.0.2 — 2022-09-11
- 1.0.1 — 2022-09-11
- 1.0.0 — 2022-09-11

## README

# CNP Decoder

A tiny and simple library that can decode a romanian CNP, extracting informations like the gender, age, the county where the user was born.


## Installation

```bash
  npm install cnp-decoder
```
    
## Usage

```js
    import { decodeCNP } from 'cnp-decoder'

    const cnpData = decodeCNP(cnp)
    // or you can destructure the values
    const { gender, birthDate, age, county, isResident } = decodeCNP(cnp)
```

### Result

| Property      | Type          | Description |
| ------------- | ------------- | ----------- |
| gender  | string  | It returns the gender of the CNP holder |
| birthDate  | Date  | It returns a Javascript date containing the date the holder was born |
| age | number | It returns the age of the holder as a number |
| county | string | It returns the county the holder lives in |
| isResident | boolean | It returns true\false depending if the user is a immigrant in Romania or not

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