@aduh95/format-phone-number
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@aduh95/format-phone-number

Simple JavaScript library that takes a phone number in the E164 format and returns it in an international format. It's using Google's libphonenumber as a source of truth for how to format a phone number.

Usage

npm install @aduh95/format-phone-number

# or if you're using yarn
yarn add @aduh95/format-phone-number
import format from "@aduh95/format-phone-number";

await format("+16135991209"); // +1 613-599-1209

// You can omit the leading `+`
await format("16135991209"); // +1 613-599-1209

Ensure that the phone number is valid and includes the country code, otherwise you'll get undefined behavior.

Build

yarn install
yarn build
yarn test

Package Sidebar

Install

npm i @aduh95/format-phone-number

Weekly Downloads

2

Version

1.0.2

License

SEE LICENSE IN LICENSE

Unpacked Size

63.5 kB

Total Files

225

Last publish

Collaborators

  • aduh95