@dhavalveera/separate-country-code-n-number
v1.1.2
Published
Separates the Country Code and Number
Downloads
713
Maintainers
Readme
@dhavalveera/separate-country-code-n-number
Separate the Country ISD Code & Phone Number
Install
npm i @dhavalveera/separate-country-code-n-number
or
yarn add @dhavalveera/separate-country-code-n-number
Usage
Command line
npx @dhavalveera/separate-country-code-n-number "+911234567890"
output:
Country ISD Code => +91
Country Name => India
Phone Number is => 1234567890
using CommonJS
const countryCode = require('@dhavalveera/separate-country-code-n-number').separateCountryCodeAndNumber
const { code, number, country } = countryCode('+911234567890')
console.log(code, number, country)
//=> +91 1234567890 India
or
const countryCode = countryCode('+911234567890').code
const phoneNumber = countryCode('+911234567890').number
const country = countryCode('+911234567890').country
console.log(countryCode, phoneNumber, country)
//=> +91 1234567890 India
using ESmodules
import { separateCountryCodeAndNumber } from '@dhavalveera/separate-country-code-n-number'
const { code, number, country } = separateCountryCodeAndNumber('+911234567890')
const { code, number, country } = countryCode('+911234567890')
//=> +91 1234567890 India
or
const countryCode = separateCountryCodeAndNumber('+911234567890').code
const phoneNumber = separateCountryCodeAndNumber('+911234567890').number
const country = separateCountryCodeAndNumber('+911234567890').country
console.log(countryCode, phoneNumber, country)
//=> +91 1234567890 India