calling-code
v0.0.2
Published
Country calling codes utils.
Downloads
34
Readme
calling-code
Country calling codes utils.
Installation
npm install calling-code
Usage
import callingCode from 'calling-code';
const phoneNumber = '+86012345678'; // '86012345678' is also ok.
const result = callingCode(phoneNumber);
result is as follows:
[
{
country: 'China',
codes: ['86'],
iso2: 'CN',
iso3: 'CHN',
body: '012345678',
},
];
Example 1
const result = callingCode('+12131234567');
[
{
country: 'Canada',
codes: ['1'],
iso2: 'CA',
iso3: 'CAN',
body: '2131234567',
},
{
country: 'United States',
codes: ['1'],
iso2: 'US',
iso3: 'USA',
body: '2131234567',
},
];
Example 2
const result = callingCode('+1-809123456');
[
{
country: 'Dominican Republic',
codes: ['1-809', '1-829', '1-849'],
iso2: 'DO',
iso3: 'DOM',
body: '123456',
},
];