catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript

Home Page:https://catamphetamine.gitlab.io/libphonenumber-js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: international template for a given country

benramsay opened this issue · comments

Is it possible to have the international template, giving the country code ?
This is sometimes necessary to guide the user like adding a placeholder string.
Some function like : getInternationalTemplate("US") => +1 xxx xxx xxxx

To have one of the possible templates, is this the "best" (or a good) way to do it

   const formatter = new AsYouType(country.code);
   formatter.input(country.dial_code);
   let template= formatter.formatter.template;
   template= country.dial_code + template.slice(country.dial_code.length);

There're many templates in a country.