npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tunisia-kit

v0.2.0

Published

A type-safe, zero-dependency toolkit for validating and formatting Tunisian data (CIN, phone, RIB, IBAN, currency, license plates)

Readme

tunisia-kit 🇹🇳

A type-safe, zero-dependency toolkit for validating and formatting Tunisian data.

npm version License: MIT

Installation

npm install tunisia-kit
# or
yarn add tunisia-kit

Quick Examples

Validating User Input

import { isValidCIN, isValidPhone, isValidRIB, isValidIBAN, isValidLandline } from 'tunisia-kit';

// Validate a National ID
isValidCIN('12345678');  // true

// Validate mobile and landline numbers
isValidPhone('22555111');     // true (Ooredoo mobile)
isValidLandline('71234567');  // true (Tunis landline)

// Validate bank accounts
isValidRIB('10005000000000000049');  // true (valid RIB)
isValidIBAN('TN5910005000000000000049'); // true (valid IBAN)

Converting RIB to IBAN

import { ribToIBAN, formatIBAN } from 'tunisia-kit';

const iban = ribToIBAN('10005000000000000049');
// → "TN5910005000000000000049"

formatIBAN(iban);
// → "TN59 1000 5000 0000 0000 0049"

Identifying Bank & Region

import { getBankFromRIB, getRegionFromLandline } from 'tunisia-kit';

getBankFromRIB('10005000000000000049'); 
// → "Banque Internationale Arabe de Tunisie (BIAT)"

getRegionFromLandline('71234567');
// → { prefix: '71', name_fr: 'Grand Tunis', name_ar: 'تونس الكبرى', ... }

Formatting for Display

import { formatPhone, formatLandline, formatCurrency } from 'tunisia-kit';

formatPhone('22555111');     // "22 555 111"
formatLandline('71234567');  // "71 234 567"
formatCurrency(1250.5);      // "1 250,500 TND"

Populating Dropdowns

import { GOVERNORATES, DELEGATIONS, getDelegationsByGovernorate } from 'tunisia-kit';

// Governorates dropdown
GOVERNORATES.map(gov => ({
  value: gov.id,
  label: gov.name_fr,     // "Tunis", "Sousse", etc.
  labelAr: gov.name_ar    // "تونس", "سوسة", etc.
}));

// Nested delegations dropdown
getDelegationsByGovernorate(1); // Returns delegations for Tunis

API Reference

Validators

| Function | Description | |----------|-------------| | isValidCIN(cin) | Validates 8-digit Tunisian National ID | | isValidPhone(phone) | Validates mobile number with provider detection | | isValidLandline(phone) | Validates landline number with region detection | | isValidRIB(rib) | Validates 20-digit bank account (Modulo 97) | | isValidIBAN(iban) | Validates 24-character Tunisian IBAN (ISO 7064) | | isValidMatricule(mat) | Validates Company Tax ID | | isValidPassport(pass) | Validates passport number | | isValidLicensePlate(plate) | Validates Tunisian license plate format |

Formatters

| Function | Input | Output | |----------|-------|--------| | formatPhone(str) | 22555111 | 22 555 111 | | formatPhoneIntl(str) | 22555111 | +216 22 555 111 | | formatLandline(str) | 71234567 | 71 234 567 | | formatLandlineIntl(str) | 71234567 | +216 71 234 567 | | formatIBAN(str) | TN59... | TN59 1000 ... | | formatCurrency(num) | 1250.5 | 1 250,500 TND | | formatCIN(str) | 4555666 | 04555666 |

Utilities

| Function | Description | |----------|-------------| | ribToIBAN(rib) | Convert 20-digit RIB to 24-character IBAN | | getBankFromRIB(rib) | Get bank name from RIB | | getRegionFromLandline(phone) | Get region info from landline prefix | | getDelegationsByGovernorate(id) | Get delegations for a governorate |

Static Data

| Export | Description | |--------|-------------| | GOVERNORATES | All 24 governorates (id, name_fr, name_ar) | | DELEGATIONS | ~260 administrative delegations across all 24 governorates | | BANKS | 21 bank codes for RIB identification | | LANDLINE_REGIONS | 8 landline prefixes with region mapping |

Phone Prefixes

Mobile

  • Tunisie Telecom: 9x, 4x
  • Ooredoo: 2x
  • Orange: 5x

Landline

  • 71: Grand Tunis
  • 72: Northeast (Nabeul, Bizerte)
  • 73: Sahel (Sousse, Monastir)
  • 74: Sfax
  • 75: Southwest (Gafsa, Tozeur)
  • 76: Southeast (Gabès, Médenine)
  • 77: Center-West (Kasserine)
  • 78: Northwest (Béja, Jendouba)

License

MIT © 2026