Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 1x 1x 1x 12x 11x 11x | import formatPhoneNumber from './formatPhoneNumber';
import parseIndicator from './parseIndicator';
/**
* Parses a phone number to a default format.
*
* @export
* @param {string} phoneNumber
* @return {string} phone number in the format `<regional indicator> (0) <phone number>`
* @example
* $ parsePhoneNumber('00999 0480/80.80.80');
* $ '+999 (0) 480 80 80 80'
*/
export default function parsePhoneNumber(phoneNumber: string): string {
const { indicator, rest } = parseIndicator(phoneNumber);
const parts: string[] = [indicator, formatPhoneNumber(rest)];
return parts.join(' ');
}
|