{"id":22202683,"url":"https://github.com/namchee/telepon","last_synced_at":"2026-03-12T05:31:03.694Z","repository":{"id":44953663,"uuid":"343387017","full_name":"Namchee/telepon","owner":"Namchee","description":"☎️ Sane and easy-to-use Indonesian phone number validator and formatter. Made with TypeScript.","archived":false,"fork":false,"pushed_at":"2024-04-22T14:43:00.000Z","size":626,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-29T16:39:39.893Z","etag":null,"topics":["formatter","phone","validation-library"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Namchee.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-03-01T11:09:21.000Z","updated_at":"2024-10-05T04:24:53.000Z","dependencies_parsed_at":"2024-04-22T16:02:07.208Z","dependency_job_id":"b6299f3b-9ea5-4b6f-bf99-7e69160dc3fa","html_url":"https://github.com/Namchee/telepon","commit_stats":{"total_commits":61,"total_committers":3,"mean_commits":"20.333333333333332","dds":0.09836065573770492,"last_synced_commit":"9f3474a8427a861302dbe5a16d89137d801da53e"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":"Namchee/liby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Namchee%2Ftelepon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Namchee%2Ftelepon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Namchee%2Ftelepon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Namchee%2Ftelepon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Namchee","download_url":"https://codeload.github.com/Namchee/telepon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227762850,"owners_count":17816094,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["formatter","phone","validation-library"],"created_at":"2024-12-02T16:36:23.451Z","updated_at":"2026-03-12T05:31:03.641Z","avatar_url":"https://github.com/Namchee.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# telepon\n\n\u003e Telepon is a sane and easy-to-use JavaScript library to parse and format Indonesian telephone number from a string.\n\n[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)\n\nParsing and formatting telephone number can be such an ass sometimes. Moreover, there's no way you can assume phone number validity just from their length and `0` prefix. Simply put, validating a phone number is not an easy task as you have consider all standards involved.\n\nWith `telepon`, not only you can format phone number easily, you can also parse a phone number from an unformatted strings easily! Moreover, this package has out-of-the-box support for TypeScript.\n\n\u003e ⚠️ **WARNING**: This package **DOES NOT** guarantee that the number is 100% callable. To do that, you have to test it yourself.\n\n## Table of Contents\n\n1. [Installation](#installation)\n2. [Data Types](#data-types)\n3. [Functions](#functions)\n4. [License](#license)\n\n## Installation\n\nInstall this package with your favorite package manager:\n\n```shell\n# using npm\nnpm install @namchee/telepon\n\n# using yarn\nyarn add @namchee/telepon\n\n# using pnpm\npnpm add @namchee/telepon\n\n# using bun\nbun install @namchee/telepon\n\n# using JSR\nnpx jsr add @namchee/telepon\n```\n\n## Data Types\n\n| **Name**           | **Description**                                                         |\n| ------------------ | ----------------------------------------------------------------------- |\n| `EmergencyService` | An emergency service number, such as law enforcement, firefighter, etc. |\n| `FixedTelepon`     | A fixed line telephone number                                           |\n| `MobileTelepon`    | A mobile cellular telephone number                                      |\n\n### Common Properties\n\nThese properties exists in all kind of `telepon`\n\n| **Name**         | **Value**                      | **Description**                                   |\n| ---------------- | ------------------------------ | ------------------------------------------------- |\n| `type`           | `emergency \\| fixed \\| mobile` | Number type                                       |\n| `originalNumber` | `string`                       | Represents parsed but unmodified telephone number |\n\n### `EmergencyService` Properties\n\nThese properties only exist in `EmergencyService`\n\n| **Name**      | **Value**   | **Description**                                         |\n| ------------- | ----------- | ------------------------------------------------------- |\n| `type`        | `emergency` | Self explanatory                                        |\n| `description` | `string`    | Describes what kind of service that the number provides |\n\n### `FixedTelepon` Properties\n\nThese properties only exist in `FixedTelepon`\n\n| **Name**           | **Value**  | **Description**                 |\n| ------------------ | ---------- | ------------------------------- |\n| `type`             | `fixed`    | Self explanatory                |\n| `unprefixedNumber` | `string`   | Telephone number without prefix |\n| `prefix`           | `string`   | Region prefix                   |\n| `region`           | `string[]` | List of possible regions        |\n| `area`             | `number`   | Area code                       |\n\n### `MobileTelepon` Properties\n\nThese properties only exist in `MobileTelepon`\n\n| **Name**   | **Value** | **Description**  |\n| ---------- | --------- | ---------------- |\n| `type`     | `mobile`  | Self explanatory |\n| `card`     | `string`  | Card type        |\n| `provider` | `string`  | Service provider |\n\n### Standard\n\nTo enhance formatting capabilites, this package provides an `enum` named `Standard` which lists all supported formattings on this package.\n\n| **Name**          | **Description**                                                                                                  |\n| ----------------- | ---------------------------------------------------------------------------------------------------------------- |\n| `Standard.E164`   | Format the number using the [E.164 Standard](https://www.itu.int/rec/T-REC-E.164/en). This is the default value. |\n| `Standard.LOCAL`  | Format the number using a commonly used format, which is `(\u003cregion_prefix\u003e) xxxx xxxx`                           |\n| `Standard.DASHED` | Same as `Standard.LOCAL`, but separated with dash `-`.                                                           |\n\n### Errors\n\n| **Name**               | **Description**                                                                           |\n| ---------------------- | ----------------------------------------------------------------------------------------- |\n| `AmbiguousNumberError` | Thrown when the number doesn't start with `0` or `+62` (if its not an `EmergencyService`) |\n| `InvalidNumberError`   | Thrown when the number is not a valid phone number in Indonesia.                          |\n\n## Functions\n### `parse(number: string)`\n\nParse a telephone number from a `string`, which includes simple sanitizing and validation. Returns an instance of either `EmergencyService`, `FixedTelepon`, or `MobileTelepon`\n\n### `parseAsEmergency(number: string)`\n\nForcefully parse a telephone number from a `string` as an `EmergencyService`. Will throw an error if the number is not an emergency service number.\n\n### `parseAsFixedLine(number: string)`\n\nForcefully parse a telephone number from a `string` as an `FixedTelepon`. Will throw an error if the number is not a fixed line telephone number.\n\n### `parseAsMobile(number: string)`\n\nForcefully parse a telephone number from a `string` as an `MobileTelepon`. Will throw an error if the number is not a cellular telephone number.\n\n### `format(telepon: FixedTelepon | MobileTelepon, standard: Standard = Standard.E164)`\n\nFormat a fixed line telephone number or a mobile cellular telephone number to a specified standard. Please note the input **MUST** be parsed first.\n\n### `tryFormat(telepon: FixedTelepon | MobileTelepon, standard: Standard = Standard.E164)`\n\nAttempt to format a fixed line telephone number or a mobile cellular telephone number to a specified standard. The input will be parsed on demand, which basically calls the `parse` function.\n\nWill throw an error if the number is invalid.\n\n## License\n\nThis project is licensed under the [MIT license](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamchee%2Ftelepon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnamchee%2Ftelepon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamchee%2Ftelepon/lists"}