UNPKG

672 BJavaScriptView Raw
1import AsYouType from './AsYouType'
2
3/**
4 * Formats a (possibly incomplete) phone number.
5 * The phone number can be either in E.164 format
6 * or in a form of national number digits.
7 * @param {string} value - A possibly incomplete phone number. Either in E.164 format or in a form of national number digits.
8 * @param {string?} country - Two-letter ("ISO 3166-1 alpha-2") country code.
9 * @return {string} Formatted (possibly incomplete) phone number.
10 */
11export default function formatIncompletePhoneNumber(value, country, metadata) {
12 if (!metadata) {
13 metadata = country
14 country = undefined
15 }
16 return new AsYouType(country, metadata).input(value)
17}
\No newline at end of file