Africa-first phone number library - CI mobile-money & carrier aware.
# afrophone
> Africa-first phone number library for JavaScript/TypeScript.
> Lightweight, carrier-aware, mobile-money-aware, multi-format output.
Lire en français →
- ** `:
```html
const r = Afrophone.parse("0707070707", "CI");
```
## Quick start
```ts
import { parse, format, isValid } from "afrophone";
parse("0707070707", "CI");
// {
// valid: true,
// e164: "+2250707070707",
// national: "07 07 07 07 07",
// international: "+225 07 07 07 07 07",
// uri: "tel:+2250707070707",
// carrier: "orange",
// portabilityCaveat: true,
// presumedMobileMoneyProviders: ["wave", "orange_money"],
// ...
// }
format("0707070707", "international", { country: "CI" });
// "+225 07 07 07 07 07"
isValid("9907070707", "CI"); // false
```
## API
### `parse(input, countryOrOptions?) → ParseResult`
Parses dirty input. Accepts spaces, dashes, dots, parentheses, leading `00` or `+`. Never throws.
```ts
parse("+225 07 07 07 07 07"); // auto-detects CI
parse("00225 0707070707"); // 00 prefix accepted
parse("0707070707", { country: "CI", locale: "fr" });
```
### `format(input, style, options?) → string`
`style` is `"e164" | "national" | "international" | "uri"`. Accepts a string or a `ParseResult` (avoids re-parsing). Returns `""` (or `options.fallback`) on invalid input.
### `isValid(input, country?) → boolean`
One-line wrapper for form validators.
### `getCarrier(input, country?) → { carrier, portabilityCaveat }`
### `getMobileMoneyProviders(input, country?) → MobileMoneyProvider[]`
Returns universal providers (Wave) first, then the carrier-aligned provider.
### `setLocale("en" | "fr")`
Module-global default locale for error messages. Per-call override is available via `parse(..., { locale })`.
## Supported countries
| Country | Code | Status |
|--------|------|--------|
| Côte d'Ivoire | `CI` | ✅ v0.1.0 |
| Sénégal, Mali, Burkina Faso | `SN` `ML` `BF` | 🔜 v0.2 |
| Bénin, Togo, Niger, Guinée | `BJ` `TG` `NE` `GN` | 🔜 v0.3 |
| …