Getting Started with degache.js

degache.js is a utility library designed specifically for Tunisian developers, providing tools for working with CIN, phone numbers, addresses, and more.

Installation

Install degache.js using your preferred package manager:

npm install degachejs

# or

yarn add degachejs

# or

pnpm add degachejs

Basic Usage

Import the functions you need from the library:

import { 
  validateCIN,
  formatPhoneNumber,
  validateTaxID,
  formatCurrency,
  validateRIB,
  getBankFromRIB,
  formatDate
} from 'degachejs';

// Validate CIN
const isCINValid = validateCIN('12345678');

// Format phone number
const phoneNumber = formatPhoneNumber('20123456');

// Validate Tax ID
const isTaxIDValid = validateTaxID('1234567A/P/M/000');

// Format currency
const price = formatCurrency(1234.56, { symbol: true });

// Validate RIB
const isRIBValid = validateRIB('12345678901234567890');

// Get bank information
const bankInfo = getBankFromRIB('12345678901234567890');

// Format date
const formattedDate = formatDate(new Date());

TypeScript Support

degache.js is written in TypeScript and provides full type definitions for all its functions and data structures. This ensures you get proper autocompletion and type checking in your IDE.

import { validateCIN, type CIN } from 'degachejs';

// TypeScript will enforce the correct type
const cin: CIN = '12345678';
const isValid = validateCIN(cin);

Next Steps

Now that you have degache.js installed, you can explore the different modules:

  • Validators - Functions for validating Tunisian-specific data formats
  • Formatters - Functions for formatting data in Tunisian conventions
  • Constants - Useful predefined data like banks, carriers, and governorates

Check out the API Reference for detailed documentation on each function.