Installation
Every module in one package
@mdgascar/utils re-exports every module — words, phone, ariary and date — with one MdgError class, so you install and import from one place.
Installing the utils bundle
Section titled “Installing the utils bundle”Choose this when an app uses several modules. Bundlers keep only the functions you import, so unused modules do not reach your users.
-
Install the bundle
Section titled “Install the bundle”Terminal npm install @mdgascar/utils -
Import from one place
Section titled “Import from one place”invoice.ts import { ariaryToWords, formatAriary, formatDate, numberToWords } from '@mdgascar/utils';formatAriary(1500); // 'Ar 1 500'ariaryToWords(1500); // 'dimanjato sy arivo ariary'formatDate('2026-11-23', 'full'); // 'Alatsinainy 23 Novambra 2026'numberToWords(21); // 'iraika amby roapolo' -
Catch errors from every module the same way
Section titled “Catch errors from every module the same way”Every module throws the same
MdgError, so onecatchcovers them all.invoice.ts import { MdgError, parseAriary } from '@mdgascar/utils';try {parseAriary('1,500');} catch (error) {if (error instanceof MdgError) console.log(error.code); // 'INVALID_FORMAT'}