{"_id":"@caspater/msisdn","_rev":"2-f2dbca7b8dad685a8d26750e1eaa81a8","name":"@caspater/msisdn","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@caspater/msisdn","version":"1.0.0","keywords":["demo","typescript"],"author":{"name":"Caspater"},"license":"MIT","_id":"@caspater/msisdn@1.0.0","maintainers":[{"name":"caspater","email":"mkapsata@gmail.com"}],"homepage":"https://github.com/caspater/msisdn","bugs":{"url":"https://github.com/caspater/msisdn/issues"},"dist":{"shasum":"d8fa815371bb887bc43c51bf582e9b524c7a3f8b","tarball":"https://registry.npmjs.org/@caspater/msisdn/-/msisdn-1.0.0.tgz","fileCount":30,"integrity":"sha512-s5PvAfztt6t5FHRazLdnFQ6laZOI+s3t0yeysVT53MGPzjS+9eRgfupynXWFv8mBlIn8uTfAyhp03mc2NxeVUw==","signatures":[{"sig":"MEQCIEs2WG16bd0t3BvdOdnQYr0lSfDP/lotESWhRE/BlPU6AiBk3vtl/RHJwGKMolIKJQ08ByLlImh659fi6ANMt9XUUQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38295},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","gitHead":"23bfeeedd7cba3812be730e24617cd8e7efe896a","scripts":{"ci":"npm run build && npm run check-format && npm run check-exports && npm run test","dev":"vitest","test":"vitest run","build":"tsc","format":"prettier --write .","check-format":"prettier --check .","check-exports":"attw --pack . --ignore-rules=cjs-resolves-to-esm","local-release":"changeset version && changeset publish","prepublishOnly":"npm run ci"},"_npmUser":{"name":"caspater","email":"mkapsata@gmail.com"},"repository":{"url":"git+https://github.com/caspater/msisdn.git","type":"git"},"_npmVersion":"10.5.2","description":"A package to format or validate msisdns (Malawi)","directories":{},"_nodeVersion":"20.13.1","_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.1.4","prettier":"^3.5.3","typescript":"^5.8.3","@changesets/cli":"^2.29.4","@arethetypeswrong/cli":"^0.18.1"},"_npmOperationalInternal":{"tmp":"tmp/msisdn_1.0.0_1748341211563_0.19606430543790454","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@caspater/msisdn","version":"1.0.1","description":"A package to format or validate msisdns (Malawi)","keywords":["msisdn","phone number"],"homepage":"https://github.com/caspater/msisdn","bugs":{"url":"https://github.com/caspater/msisdn/issues"},"scripts":{"ci":"npm run build && npm run check-format && npm run check-exports && npm run test","build":"tsc","format":"prettier --write .","check-format":"prettier --check .","check-exports":"attw --pack . --ignore-rules=cjs-resolves-to-esm","test":"vitest run","dev":"vitest","local-release":"changeset version && changeset publish","prepublishOnly":"npm run ci"},"author":{"name":"Caspater"},"repository":{"type":"git","url":"git+https://github.com/caspater/msisdn.git"},"main":"dist/index.js","type":"module","license":"MIT","devDependencies":{"@arethetypeswrong/cli":"^0.18.1","@changesets/cli":"^2.29.4","prettier":"^3.5.3","typescript":"^5.8.3","vitest":"^3.1.4"},"_id":"@caspater/msisdn@1.0.1","gitHead":"375f78667fe460bf33bfa4a5c10701fcab60904a","types":"./dist/index.d.ts","_nodeVersion":"20.13.1","_npmVersion":"10.5.2","dist":{"integrity":"sha512-ZuH4ZpDFTAzR7EK/mOBMnGxV4bH7p4lXKJfVSPCh0PC0nQESgXdaK4m6a1RbzGYYrQS10FthiRzxKBnufg1aSA==","shasum":"1dbcc6f26822bb1f61c1438b4c43771e2c71f312","tarball":"https://registry.npmjs.org/@caspater/msisdn/-/msisdn-1.0.1.tgz","fileCount":66,"unpackedSize":84456,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDrOGHw0YRR3XZtmic2S7Bs6rKDDAYF6Dh4d/lyhrFVtAiAsuHyxVNP2Km2b6A7LiG1SQM1lSS15GbDkAgdab7ty6w=="}]},"_npmUser":{"name":"caspater","email":"mkapsata@gmail.com","actor":{"name":"caspater","email":"mkapsata@gmail.com","type":"user"}},"directories":{},"maintainers":[{"name":"caspater","email":"mkapsata@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/msisdn_1.0.1_1750427448208_0.017132572335887497"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-27T10:20:11.434Z","modified":"2025-06-20T13:50:48.556Z","1.0.0":"2025-05-27T10:20:11.737Z","1.0.1":"2025-06-20T13:50:48.385Z"},"bugs":{"url":"https://github.com/caspater/msisdn/issues"},"author":{"name":"Caspater"},"license":"MIT","homepage":"https://github.com/caspater/msisdn","keywords":["msisdn","phone number"],"repository":{"type":"git","url":"git+https://github.com/caspater/msisdn.git"},"description":"A package to format or validate msisdns (Malawi)","maintainers":[{"name":"caspater","email":"mkapsata@gmail.com"}],"readme":"# MSISDN HELPER\n\nThis project is focused on validating and formatting MSISDNs (Mobile Station International Subscriber Directory Number).\n\n## Features\n\n- Validate MSISDN numbers.\n- Format and normalize phone numbers.\n- Support for multiple country codes.\n\n## Installation\n\n1. npm installation.\n   ```bash\n   npm install @caspater/msisdn\n   ```\n\n## Usage\n\nImport the library and use it in your project:\n\n```typescript\nimport { msisdn } from '@caspater/msisdn';\n\nconst isValid = msisdn('0888800900').isValid();\nconsole.log(isValid);\n```\n\n### Creating a new number\n\nThe `msisdn` helper function creates an instance of MSISDN. You can use the `get` method to invoke the toString method.\n\n```typescript\nimport { msisdn } from '@caspater/msisdn';\n\nconst msisdnInstance = msisdn('0888800900');\nconsole.log(msisdnInstance.get());\n//output 888800900\n```\n\n#### Options\n\nThe `msisdn` factory allows a second parameter to set the configs of the instance\n\n```typescript\ntype options = {\n  autoClean?: boolean; //default true,\n  country?: string; //default MW,\n  type?: string; //default null,\n};\n```\n\n| option    | Required  | Description                                                                                                                                                                                                        |\n| --------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| autoClean | optional? | This removes special characters from the msisdn when it is set to `true`. By default it is set to true. It can set it to `false` in situations where the number format is to be validated.                         |\n| country   | optional? | This is used to set the country. The list of supported countries can be found in the list [below](#supported-countries).                                                                                           |\n| type      | optional? | This is used to set the type. The types can be identifies as areas/providers depending on the number structure of the country. The list of supported types can be found in the list [below](#supported-countries). |\n\n### Validation\n\nThe `isValid` function can be used to validate the msisdn. **Note** set the `autoClean` option to `false` if the special characters are to be validated as well.\n\nThe `isValid` function will also use the configured country / type as validators.\n\n```typescript\nimport { msisdn } from '@caspater/msisdn';\n\nconst msisdnInstance = msisdn('08-88800900', { autoClean: false });\nconsole.log(msisdnInstance.isValid());\n//output false\n```\n\n### Formatting\n\nThe formatting helpers will return the MSISDN instance so chaining can be used to apply multiple formats. Of course some may be overwritten , you can't have everything 😁\n\n| Function         | Parameters          | Format                 | Description                                             |\n| ---------------- | ------------------- | ---------------------- | ------------------------------------------------------- |\n| clean            |                     | #####                  | Removes special characters from the msisdn              |\n| internationalize | `withPlus: boolean` | {+?}{countryCode}##### | Prepends the country code                               |\n| localize         |                     | {0}#####               | Prepends a 0 to the msisdn                              |\n| humanize         |                     | {0}#####               | Prepends a 0 to the msisdn                              |\n| dropLeading      |                     | #####                  | Drops the country code or the leading 0 from the msisdn |\n\n### Getters\n\nThe string version of the msisdn can be retrieved by using the `get` function.\n\n| Function | Description                                     |\n| -------- | ----------------------------------------------- |\n| get      | Gets the msisdn only when it is **_valid_**     |\n| getRaw   | Gets the msisdn even when it is **_not valid_** |\n\n## <a id=\"supported-countries\"></a>Supported Countries\n\n| Country                                                                            | Code | Type     | Type Identifier |\n| ---------------------------------------------------------------------------------- | ---- | -------- | --------------- |\n| Malawi                                                                             | MW   | TNM      | TNM             |\n|                                                                                    |      | Airtel   | Airtel          |\n|                                                                                    |      | Access   | Access          |\n|                                                                                    |      | MTL      | MTL             |\n| Zambia                                                                             | ZM   | MTN      | MTN             |\n|                                                                                    |      | Airtel   | Airtel          |\n|                                                                                    |      | Zamtel   | Zamtel          |\n| Tanzania(The numbers are potable so type validation may not be accurate sometimes) | TZ   | Vodacom  | Vodacom         |\n|                                                                                    |      | Airtel   | Airtel          |\n|                                                                                    |      | Tigo     | Tigo            |\n|                                                                                    |      | Halotel  | Halotel         |\n|                                                                                    |      | Zantel   | Zantel          |\n|                                                                                    |      | Smile    | Smile           |\n|                                                                                    |      | TTCL     | TTCL            |\n| Nigeria                                                                            | NG   | Portable | Portable        |\n| Rwanda                                                                             | RW   | MTN      | MTN             |\n|                                                                                    |      | Airtel   | Airtel          |\n| South Africa                                                                       | ZA   | Portable | Portable        |\n\n## Contributing\n\nContributions are welcome! Please fork the repository and submit a pull request.\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/caspater/msisdn.git\n   ```\n2. Navigate to the project directory:\n   ```bash\n   cd msisdn\n   ```\n3. Install dependencies:\n   ```bash\n   npm install\n   ```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","readmeFilename":"README.md"}