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

1.0.1 • Public • Published

@shopify/phone

Build Status Build Status License: MIT npm version npm bundle size (minified + gzip)

Phone number utilities for formatting phone numbers.

Installation

yarn add @shopify/phone

PhoneNumberFormatter methods

import PhoneNumberFormatter from '@shopify/phone';

// Pass a region code to the constructor
const phoneFormatter = new PhoneNumberFormatter('US');
const formatted = phoneFormatter.format(myPhoneNumber);

format(phoneNumber: string): string

Formats the given phone number

update(regionCode: string): void

Update formatter regionCode which will format number based on that (eg: 'CA' | 'JP' etc.)

getNormalizedNumber(phoneNumber: string): string

Returns phone number in E164 format

getNationalNumber(phoneNumber: string): string

Returns the non-formatted version without the country code

requiresItalianLeadingZero(phoneNumber: string)

Indicates if the leading zero of a national number should be retained when dialling internationally

updateCountryCode(phoneNumber: string): void

Updates the country code of the formatter based on the phoneNumber passed

Exported functions

getRegionCodeFromNumber(phoneNumber: string): string

Returns the region code from the provided phone number

getCountryCodeFromNumber(phoneNumber: string): number | undefined

Returns the country code from the provided phone number

Readme

Keywords

none

Package Sidebar

Install

npm i @shopify/phone

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

28.9 kB

Total Files

20

Last publish

Collaborators

  • jaimie.rockburn
  • blittle
  • shopify-admin
  • maryharte
  • crisfmb
  • pmoloney89
  • netlohan
  • st999999
  • justin-irl
  • megswim
  • wcandillon
  • nathanpjf
  • shopify-dep
  • goodforonefare
  • lemonmade
  • vsumner
  • wizardlyhel
  • antoine.grant
  • tsov
  • andyw8-shopify
  • henrytao
  • hannachen
  • vividviolet
  • bpscott