lib/extractor.js
function(n, countryCode){

        const number = phoneUtil.parse(n, countryCode),
            isPossibleNumber = phoneUtil.isPossibleNumber(number),
	        res = {
                input: n,
                countryCode: countryCode,
                isPossibleNumber: isPossibleNumber,
                isPossibleNumberWithReason: phoneUtil.isPossibleNumberWithReason(number)
	        };

        if(isPossibleNumber){
            res.isPossibleNumber = true;
            res.isNumberValid = phoneUtil.isValidNumber(number);
            res.countryCode = countryCode;
            res.formatted = phoneUtil.formatInOriginalFormat(number, countryCode);
            res.national = phoneUtil.format(number, PNF.NATIONAL);
            res.international = phoneUtil.format(number, PNF.INTERNATIONAL)
        }

        switch (phoneUtil.isPossibleNumberWithReason(number)){

            case PNV.IS_POSSIBLE:
                res.isPossibleNumberWithReason = 'IS_POSSIBLE';
            break;

            case PNV.INVALID_COUNTRY_CODE:
                res.isPossibleNumberWithReason = 'INVALID_COUNTRY_CODE';
            break;

            case PNV.TOO_SHORT:
                res.isPossibleNumberWithReason = 'TOO_SHORT';
            break;

            case PNV.TOO_LONG:
                res.isPossibleNumberWithReason = 'TOO_LONG';
            break;
        }

        return res;
    }
function(n, countryCode){

        const number = phoneUtil.parse(n, countryCode),
            isPossibleNumber = phoneUtil.isPossibleNumber(number),
	        res = {
                input: n,
                countryCode: countryCode,
                isPossibleNumber: isPossibleNumber,
                isPossibleNumberWithReason: phoneUtil.isPossibleNumberWithReason(number)
	        };

        if(isPossibleNumber){
            res.isPossibleNumber = true;
            res.isNumberValid = phoneUtil.isValidNumber(number);
            res.countryCode = countryCode;
            res.formatted = phoneUtil.formatInOriginalFormat(number, countryCode);
            res.national = phoneUtil.format(number, PNF.NATIONAL);
            res.international = phoneUtil.format(number, PNF.INTERNATIONAL)
        }

        switch (phoneUtil.isPossibleNumberWithReason(number)){

            case PNV.IS_POSSIBLE:
                res.isPossibleNumberWithReason = 'IS_POSSIBLE';
            break;

            case PNV.INVALID_COUNTRY_CODE:
                res.isPossibleNumberWithReason = 'INVALID_COUNTRY_CODE';
            break;

            case PNV.TOO_SHORT:
                res.isPossibleNumberWithReason = 'TOO_SHORT';
            break;

            case PNV.TOO_LONG:
                res.isPossibleNumberWithReason = 'TOO_LONG';
            break;
        }

        return res;
    }
function ( n , countryCode ) { const number = phoneUtil . parse ( n , countryCode ) , isPossibleNumber = phoneUtil . isPossibleNumber ( number ) , res = { input : n , countryCode : countryCode , isPossibleNumber : isPossibleNumber , isPossibleNumberWithReason : phoneUtil . isPossibleNumberWithReason ( number ) } ; if ( isPossibleNumber ) { res . isPossibleNumber = true ; res . isNumberValid = phoneUtil . isValidNumber ( number ) ; res . countryCode = countryCode ; res . formatted = phoneUtil . formatInOriginalFormat ( number , countryCode ) ; res . national = phoneUtil . format ( number , PNF . NATIONAL ) ; res . international = phoneUtil . format ( number , PNF . INTERNATIONAL ) } switch ( phoneUtil . isPossibleNumberWithReason ( number ) ) { case PNV . IS_POSSIBLE : res . isPossibleNumberWithReason = 'IS_POSSIBLE' ; break ; case PNV . INVALID_COUNTRY_CODE : res . isPossibleNumberWithReason = 'INVALID_COUNTRY_CODE' ; break ; case PNV . TOO_SHORT : res . isPossibleNumberWithReason = 'TOO_SHORT' ; break ; case PNV . TOO_LONG : res . isPossibleNumberWithReason = 'TOO_LONG' ; break ; } return res ; }
Uses Google LibPhoneNumber to format and verify the number
@param {number|string} n
@param {string} countryCode
@return {object}
Uses Google LibPhoneNumber to format and verify the number