Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 929 Bytes

README.md

File metadata and controls

30 lines (21 loc) · 929 Bytes

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

  npm install cnp-decoder

Usage

    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