{"_id":"@dolphfi_/haiti-utils","_rev":"4-d148b0e93101e74ac2b1d2487f00a8d0","name":"@dolphfi_/haiti-utils","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.1":{"name":"@dolphfi_/haiti-utils","version":"1.0.1","keywords":["haiti","departments","communes","utils","geography","postal-code","phone-number"],"author":{"name":"Rodolph Phayendy Delon Fidèle"},"license":"MIT","_id":"@dolphfi_/haiti-utils@1.0.1","maintainers":[{"name":"dolphfi_","email":"rodolphfidele@gmail.com"}],"homepage":"https://github.com/dolphfi/haiti-utils#readme","bugs":{"url":"https://github.com/dolphfi/haiti-utils/issues"},"dist":{"shasum":"c80c2d0f8d6d533f1ac5200486ebde07b0a49cdb","tarball":"https://registry.npmjs.org/@dolphfi_/haiti-utils/-/haiti-utils-1.0.1.tgz","fileCount":16,"integrity":"sha512-kLJbBlNRfladoyAhbyKMij5FJKjsAbb4b+yC5eKSgF4cXyv+OfWsSogMyMXXzjqZG7jKdU4KDB+BaOJsiXuROQ==","signatures":[{"sig":"MEYCIQC5n+U5zXWH5WFBZhM6Cwj9dnOsf2IFsYNinb0Zdrr73wIhAPfL6qx/0E4Y1rwrsvViOr5hCNAFzIP5q5BABBpN9umh","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35975},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"d687eb292ee37b624b038d8d8559a62e38b0324e","scripts":{"test":"bun test","build":"tsc","prepublishOnly":"bun run build"},"_npmUser":{"name":"dolphfi_","email":"rodolphfidele@gmail.com"},"repository":{"url":"git+https://github.com/dolphfi/haiti-utils.git","type":"git"},"_npmVersion":"10.8.2","description":"A simple utility package to get geographical data about Haiti, such as departments and communes.","directories":{},"_nodeVersion":"20.19.4","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/haiti-utils_1.0.1_1757397336761_0.18338535789397326","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@dolphfi_/haiti-utils","version":"1.1.0","publishConfig":{"access":"public"},"description":"A simple utility package to get geographical data about Haiti, such as departments and communes.","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"type":"module","scripts":{"build":"tsc","test":"bun test","prepublishOnly":"bun run build"},"keywords":["haiti","departments","communes","utils","geography","postal-code","phone-number"],"author":{"name":"Rodolph Phayendy Delon Fidèle"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/dolphfi/haiti-utils.git"},"devDependencies":{"@types/bun":"latest","typescript":"^5.0.0"},"_id":"@dolphfi_/haiti-utils@1.1.0","gitHead":"69568cfdd7192a622d2af415115e4d562a7d9cc9","bugs":{"url":"https://github.com/dolphfi/haiti-utils/issues"},"homepage":"https://github.com/dolphfi/haiti-utils#readme","_nodeVersion":"22.23.1","_npmVersion":"10.9.8","dist":{"integrity":"sha512-IRSVlLlUKnFnTY7VlXPraLqz6uxjQQBCaSwYMoPtQ/r844E70pjMWmyRpslJrjpoA1jE+hZjUNbmEcKCG3y1pQ==","shasum":"f1edd9a487d0ce1a707f150a45e317b784e55049","tarball":"https://registry.npmjs.org/@dolphfi_/haiti-utils/-/haiti-utils-1.1.0.tgz","fileCount":32,"unpackedSize":63349,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIG+BFFUxQCUjgYQGTRfFAT/LYUwCUzk3V+OPi5pMZ/ggAiEAvVectdOjk3dmoBkJFkMiZ+CUTMuPIrq4l+sx3t0DqrA="}]},"_npmUser":{"name":"dolphfi_","email":"rodolphfidele@gmail.com"},"directories":{},"maintainers":[{"name":"dolphfi_","email":"rodolphfidele@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/haiti-utils_1.1.0_1784391460620_0.8935766213064043"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-09T05:55:36.637Z","modified":"2026-07-18T16:17:40.887Z","1.0.0":"2025-09-09T04:40:52.248Z","1.0.1":"2025-09-09T05:55:36.931Z","1.1.0":"2026-07-18T16:17:40.752Z"},"bugs":{"url":"https://github.com/dolphfi/haiti-utils/issues"},"author":{"name":"Rodolph Phayendy Delon Fidèle"},"license":"MIT","homepage":"https://github.com/dolphfi/haiti-utils#readme","keywords":["haiti","departments","communes","utils","geography","postal-code","phone-number"],"repository":{"type":"git","url":"git+https://github.com/dolphfi/haiti-utils.git"},"description":"A simple utility package to get geographical data about Haiti, such as departments and communes.","maintainers":[{"name":"dolphfi_","email":"rodolphfidele@gmail.com"}],"readme":"[English](./README.md) | [Français](./README.fr.md) | [Kreyòl Ayisyen](./README.ht.md)\n\n# Haiti Utils\n\n[![npm version](https://img.shields.io/npm/v/@dolphfi_/haiti-utils.svg)](https://www.npmjs.com/package/@dolphfi_/haiti-utils)\n\n`haiti-utils` is a lightweight, zero-dependency npm package that provides simple and reliable utilities for working with Haitian geographical data.\n\n## Why use `haiti-utils`?\n\n- **Save Time**: Stop searching for and hardcoding lists of departments, communes, or postal codes.\n- **Reliable Data**: Access a complete and structured dataset for all 10 departments.\n- **Easy to Use**: A simple and intuitive API that is fully typed with TypeScript.\n- **Case-Insensitive**: All search functions are case-insensitive for a better developer experience.\n\n## Installation\n\n```bash\nnpm install haiti-utils\n# or\nyarn add haiti-utils\n# or\nbun add haiti-utils\n```\n\n## Usage\n\nHere are a few examples of how to use the package.\n\n### Get a list of all departments\n\n```typescript\nimport { getDepartments } from 'haiti-utils';\n\nconst departments = getDepartments();\nconsole.log(departments);\n// Output: [\"Artibonite\", \"Centre\", ...]\n```\n\n### Get the communes of a specific department\n\n```typescript\nimport { getCommunes } from 'haiti-utils';\n\n// The search is case-insensitive\nconst communes = getCommunes('Ouest'); \nconsole.log(communes);\n// Output: [\"Arcahaie\", \"Cabaret\", ...]\n```\n\n### Get the postal code of a commune\n\n```typescript\nimport { getPostalCode } from 'haiti-utils';\n\n// The search is case-insensitive for both department and commune\nconst postalCode = getPostalCode('Ouest', 'Pétion-Ville');\nconsole.log(postalCode);\n// Output: \"HT6122\"\n\nconst notFound = getPostalCode('Nord', 'InvalidCommune');\nconsole.log(notFound);\n// Output: null\n```\n\n### Get all data\n\n```typescript\nimport { getAllData } from 'haiti-utils';\n\nconst allData = getAllData();\nconsole.log(allData[0].department); // \"Artibonite\"\nconsole.log(allData[0].communes[0].name); // \"Dessalines\"\n```\n\n### Validate a phone number\n\n```typescript\nimport { validatePhoneNumber } from 'haiti-utils';\n\nvalidatePhoneNumber('+509 34 56 78 90'); // true\nvalidatePhoneNumber('55555555'); // false\n```\n\n### Format a phone number\n\n```typescript\nimport { formatPhoneNumber } from 'haiti-utils';\n\n// Default format (international)\nformatPhoneNumber('34567890'); // \"+509 34 56 78 90\"\n\n// National format\nformatPhoneNumber('+509 34.56.78.90', { format: 'national' }); // \"3456-7890\"\n\n// Compact format\nformatPhoneNumber('34567890', { format: 'compact' }); // \"+50934567890\"\n\n// Invalid number\nformatPhoneNumber('12345'); // null\n```\n\n## API Reference\n\n### `getDepartments(): string[]`\n\nReturns a list of all department names.\n\n### `getCommunes(department: string): string[]`\n\nReturns a list of all communes for a given department. The search is case-insensitive. Returns an empty array if the department is not found.\n\n### `getPostalCode(department: string, commune: string): string | null`\n\nReturns the postal code for a specific commune within a department. The search is case-insensitive for both department and commune. Returns `null` if not found or not available.\n\n### `getAllData(): DepartmentData[]`\n\nReturns the complete dataset of all departments and their communes.\n\n### `validatePhoneNumber(phoneNumber: string): boolean`\n\nValidates a Haitian phone number. It handles common formats, including the `+509` country code, and ignores spaces or hyphens. Returns `true` if the number is valid, `false` otherwise.\n\n### `formatPhoneNumber(phoneNumber: string, options?: { format: 'international' | 'national' | 'compact' }): string | null`\n\nFormats a Haitian phone number into a consistent, readable format. If the number is invalid, it returns `null`. The default format is `international`.\n\n## Contributing\n\nContributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/dolphfi/haiti-utils/issues).\n\n\n## 💖 Sponsor\n\nSi ou jwenn pake **haiti-utils** itil, ou ka sipòte devlopman li.\n\n👉 [Become a Sponsor on GitHub](https://github.com/sponsors/dolphfi)","readmeFilename":"README.md"}