libphonenumber-js 1.12.9 → 1.12.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CODE_OF_CONDUCT.md +78 -78
- package/README.md +2 -3
- package/build/AsYouType.js +69 -131
- package/build/AsYouType.js.map +1 -1
- package/build/AsYouType.test.js +610 -553
- package/build/AsYouType.test.js.map +1 -1
- package/build/AsYouTypeFormatter.PatternMatcher.js +29 -77
- package/build/AsYouTypeFormatter.PatternMatcher.js.map +1 -1
- package/build/AsYouTypeFormatter.PatternMatcher.test.js +107 -109
- package/build/AsYouTypeFormatter.PatternMatcher.test.js.map +1 -1
- package/build/AsYouTypeFormatter.PatternParser.js +34 -67
- package/build/AsYouTypeFormatter.PatternParser.js.map +1 -1
- package/build/AsYouTypeFormatter.PatternParser.test.js +7 -9
- package/build/AsYouTypeFormatter.PatternParser.test.js.map +1 -1
- package/build/AsYouTypeFormatter.complete.js +18 -28
- package/build/AsYouTypeFormatter.complete.js.map +1 -1
- package/build/AsYouTypeFormatter.js +193 -233
- package/build/AsYouTypeFormatter.js.map +1 -1
- package/build/AsYouTypeFormatter.util.js +11 -38
- package/build/AsYouTypeFormatter.util.js.map +1 -1
- package/build/AsYouTypeFormatter.util.test.js +6 -7
- package/build/AsYouTypeFormatter.util.test.js.map +1 -1
- package/build/AsYouTypeParser.js +89 -143
- package/build/AsYouTypeParser.js.map +1 -1
- package/build/AsYouTypeState.js +13 -23
- package/build/AsYouTypeState.js.map +1 -1
- package/build/ParseError.js +22 -43
- package/build/ParseError.js.map +1 -1
- package/build/PhoneNumber.js +46 -85
- package/build/PhoneNumber.js.map +1 -1
- package/build/PhoneNumber.test.js +41 -33
- package/build/PhoneNumber.test.js.map +1 -1
- package/build/PhoneNumberMatcher.js +67 -101
- package/build/PhoneNumberMatcher.js.map +1 -1
- package/build/PhoneNumberMatcher.test.js +35 -18
- package/build/PhoneNumberMatcher.test.js.map +1 -1
- package/build/constants.js +17 -19
- package/build/constants.js.map +1 -1
- package/build/findNumbers/LRUCache.js +23 -34
- package/build/findNumbers/LRUCache.js.map +1 -1
- package/build/findNumbers/Leniency.js +58 -114
- package/build/findNumbers/Leniency.js.map +1 -1
- package/build/findNumbers/RegExpCache.js +9 -20
- package/build/findNumbers/RegExpCache.js.map +1 -1
- package/build/findNumbers/isValidCandidate.js +12 -19
- package/build/findNumbers/isValidCandidate.js.map +1 -1
- package/build/findNumbers/isValidPreCandidate.js +5 -7
- package/build/findNumbers/isValidPreCandidate.js.map +1 -1
- package/build/findNumbers/matchPhoneNumberStringAgainstPhoneNumber.js +9 -15
- package/build/findNumbers/matchPhoneNumberStringAgainstPhoneNumber.js.map +1 -1
- package/build/findNumbers/parsePreCandidate.js +0 -3
- package/build/findNumbers/parsePreCandidate.js.map +1 -1
- package/build/findNumbers/utf-8.js +9 -13
- package/build/findNumbers/utf-8.js.map +1 -1
- package/build/findNumbers/util.js +1 -8
- package/build/findNumbers/util.js.map +1 -1
- package/build/findNumbers/util.test.js +9 -15
- package/build/findNumbers/util.test.js.map +1 -1
- package/build/findPhoneNumbersInText.js +10 -17
- package/build/findPhoneNumbersInText.js.map +1 -1
- package/build/findPhoneNumbersInText.test.js +100 -93
- package/build/findPhoneNumbersInText.test.js.map +1 -1
- package/build/format.js +31 -64
- package/build/format.js.map +1 -1
- package/build/format.test.js +133 -119
- package/build/format.test.js.map +1 -1
- package/build/formatIncompletePhoneNumber.js +1 -5
- package/build/formatIncompletePhoneNumber.js.map +1 -1
- package/build/formatIncompletePhoneNumber.test.js +14 -13
- package/build/formatIncompletePhoneNumber.test.js.map +1 -1
- package/build/formatPhoneNumberForMobileDialing.js +32 -32
- package/build/formatPhoneNumberForMobileDialing.js.map +1 -1
- package/build/getCountries.js +1 -4
- package/build/getCountries.js.map +1 -1
- package/build/getCountries.test.js +2 -5
- package/build/getCountries.test.js.map +1 -1
- package/build/getCountryCallingCode.js +0 -1
- package/build/getCountryCallingCode.js.map +1 -1
- package/build/getCountryCallingCode.test.js +2 -5
- package/build/getCountryCallingCode.test.js.map +1 -1
- package/build/getExampleNumber.js +1 -4
- package/build/getExampleNumber.js.map +1 -1
- package/build/getExampleNumber.test.js +5 -9
- package/build/getExampleNumber.test.js.map +1 -1
- package/build/helpers/RFC3966.js +16 -38
- package/build/helpers/RFC3966.js.map +1 -1
- package/build/helpers/RFC3966.test.js +16 -14
- package/build/helpers/RFC3966.test.js.map +1 -1
- package/build/helpers/applyInternationalSeparatorStyle.js +0 -2
- package/build/helpers/applyInternationalSeparatorStyle.js.map +1 -1
- package/build/helpers/applyInternationalSeparatorStyle.test.js +3 -5
- package/build/helpers/applyInternationalSeparatorStyle.test.js.map +1 -1
- package/build/helpers/checkNumberLength.js +18 -22
- package/build/helpers/checkNumberLength.js.map +1 -1
- package/build/helpers/checkNumberLength.test.js +19 -27
- package/build/helpers/checkNumberLength.test.js.map +1 -1
- package/build/helpers/extension/createExtensionPattern.js +19 -35
- package/build/helpers/extension/createExtensionPattern.js.map +1 -1
- package/build/helpers/extension/extractExtension.js +6 -12
- package/build/helpers/extension/extractExtension.js.map +1 -1
- package/build/helpers/extractCountryCallingCode.js +14 -24
- package/build/helpers/extractCountryCallingCode.js.map +1 -1
- package/build/helpers/extractCountryCallingCode.test.js +4 -7
- package/build/helpers/extractCountryCallingCode.test.js.map +1 -1
- package/build/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +4 -16
- package/build/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js.map +1 -1
- package/build/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js +16 -29
- package/build/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js.map +1 -1
- package/build/helpers/extractNationalNumber.js +10 -21
- package/build/helpers/extractNationalNumber.js.map +1 -1
- package/build/helpers/extractNationalNumber.test.js +2 -8
- package/build/helpers/extractNationalNumber.test.js.map +1 -1
- package/build/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +12 -18
- package/build/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js.map +1 -1
- package/build/helpers/extractNationalNumberFromPossiblyIncompleteNumber.test.js +2 -6
- package/build/helpers/extractNationalNumberFromPossiblyIncompleteNumber.test.js.map +1 -1
- package/build/helpers/extractPhoneContext.js +19 -28
- package/build/helpers/extractPhoneContext.js.map +1 -1
- package/build/helpers/extractPhoneContext.test.js +12 -15
- package/build/helpers/extractPhoneContext.test.js.map +1 -1
- package/build/helpers/formatNationalNumberUsingFormat.js +7 -13
- package/build/helpers/formatNationalNumberUsingFormat.js.map +1 -1
- package/build/helpers/getCountryByCallingCode.js +5 -14
- package/build/helpers/getCountryByCallingCode.js.map +1 -1
- package/build/helpers/getCountryByNationalNumber.js +18 -20
- package/build/helpers/getCountryByNationalNumber.js.map +1 -1
- package/build/helpers/getIddPrefix.js +4 -8
- package/build/helpers/getIddPrefix.js.map +1 -1
- package/build/helpers/getNumberType.js +23 -35
- package/build/helpers/getNumberType.js.map +1 -1
- package/build/helpers/getNumberType.test.js +4 -8
- package/build/helpers/getNumberType.test.js.map +1 -1
- package/build/helpers/getPossibleCountriesForNumber.js +1 -11
- package/build/helpers/getPossibleCountriesForNumber.js.map +1 -1
- package/build/helpers/isObject.js +0 -1
- package/build/helpers/isObject.js.map +1 -1
- package/build/helpers/isViablePhoneNumber.js +19 -19
- package/build/helpers/isViablePhoneNumber.js.map +1 -1
- package/build/helpers/matchesEntirely.js +0 -1
- package/build/helpers/matchesEntirely.js.map +1 -1
- package/build/helpers/matchesEntirely.test.js +4 -5
- package/build/helpers/matchesEntirely.test.js.map +1 -1
- package/build/helpers/mergeArrays.js +6 -11
- package/build/helpers/mergeArrays.js.map +1 -1
- package/build/helpers/mergeArrays.test.js +2 -4
- package/build/helpers/mergeArrays.test.js.map +1 -1
- package/build/helpers/parseDigits.js +7 -17
- package/build/helpers/parseDigits.js.map +1 -1
- package/build/helpers/parseDigits.test.js +2 -4
- package/build/helpers/parseDigits.test.js.map +1 -1
- package/build/helpers/stripIddPrefix.js +7 -17
- package/build/helpers/stripIddPrefix.js.map +1 -1
- package/build/helpers/stripIddPrefix.test.js +4 -7
- package/build/helpers/stripIddPrefix.test.js.map +1 -1
- package/build/isPossible.js +3 -15
- package/build/isPossible.js.map +1 -1
- package/build/isPossible.test.js +34 -41
- package/build/isPossible.test.js.map +1 -1
- package/build/isPossiblePhoneNumber.js +10 -15
- package/build/isPossiblePhoneNumber.js.map +1 -1
- package/build/isPossiblePhoneNumber.test.js +11 -17
- package/build/isPossiblePhoneNumber.test.js.map +1 -1
- package/build/isValid.js +7 -11
- package/build/isValid.js.map +1 -1
- package/build/isValid.test.js +59 -58
- package/build/isValid.test.js.map +1 -1
- package/build/isValidPhoneNumber.js +10 -15
- package/build/isValidPhoneNumber.js.map +1 -1
- package/build/isValidPhoneNumber.test.js +10 -15
- package/build/isValidPhoneNumber.test.js.map +1 -1
- package/build/legacy/findNumbers.js +4 -11
- package/build/legacy/findNumbers.js.map +1 -1
- package/build/legacy/findNumbers.test.js +77 -63
- package/build/legacy/findNumbers.test.js.map +1 -1
- package/build/legacy/findPhoneNumbers.js +11 -21
- package/build/legacy/findPhoneNumbers.js.map +1 -1
- package/build/legacy/findPhoneNumbers.test.js +75 -72
- package/build/legacy/findPhoneNumbers.test.js.map +1 -1
- package/build/legacy/findPhoneNumbersInitialImplementation.js +34 -62
- package/build/legacy/findPhoneNumbersInitialImplementation.js.map +1 -1
- package/build/legacy/format.js +28 -44
- package/build/legacy/format.js.map +1 -1
- package/build/legacy/format.test.js +119 -103
- package/build/legacy/format.test.js.map +1 -1
- package/build/legacy/getNumberType.js +30 -44
- package/build/legacy/getNumberType.js.map +1 -1
- package/build/legacy/getNumberType.test.js +31 -34
- package/build/legacy/getNumberType.test.js.map +1 -1
- package/build/legacy/isPossibleNumber.js +5 -11
- package/build/legacy/isPossibleNumber.js.map +1 -1
- package/build/legacy/isPossibleNumber.test.js +22 -25
- package/build/legacy/isPossibleNumber.test.js.map +1 -1
- package/build/legacy/isValidNumber.js +5 -11
- package/build/legacy/isValidNumber.js.map +1 -1
- package/build/legacy/isValidNumber.test.js +41 -39
- package/build/legacy/isValidNumber.test.js.map +1 -1
- package/build/legacy/isValidNumberForRegion.js +4 -12
- package/build/legacy/isValidNumberForRegion.js.map +1 -1
- package/build/legacy/isValidNumberForRegion.test.js +6 -11
- package/build/legacy/isValidNumberForRegion.test.js.map +1 -1
- package/build/legacy/isValidNumberForRegion_.js +1 -4
- package/build/legacy/isValidNumberForRegion_.js.map +1 -1
- package/build/legacy/parse.js +4 -9
- package/build/legacy/parse.js.map +1 -1
- package/build/legacy/parse.test.js +233 -194
- package/build/legacy/parse.test.js.map +1 -1
- package/build/legacy/searchNumbers.js +8 -12
- package/build/legacy/searchNumbers.js.map +1 -1
- package/build/legacy/searchNumbers.test.js +6 -14
- package/build/legacy/searchNumbers.test.js.map +1 -1
- package/build/metadata.js +85 -122
- package/build/metadata.js.map +1 -1
- package/build/metadata.test.js +54 -80
- package/build/metadata.test.js.map +1 -1
- package/build/normalizeArguments.js +25 -35
- package/build/normalizeArguments.js.map +1 -1
- package/build/parse.js +66 -116
- package/build/parse.js.map +1 -1
- package/build/parse.test.js +244 -206
- package/build/parse.test.js.map +1 -1
- package/build/parseIncompletePhoneNumber.js +8 -18
- package/build/parseIncompletePhoneNumber.js.map +1 -1
- package/build/parseIncompletePhoneNumber.test.js +24 -25
- package/build/parseIncompletePhoneNumber.test.js.map +1 -1
- package/build/parsePhoneNumber.js +4 -9
- package/build/parsePhoneNumber.js.map +1 -1
- package/build/parsePhoneNumber.test.js +14 -25
- package/build/parsePhoneNumber.test.js.map +1 -1
- package/build/parsePhoneNumberWithError.js +4 -9
- package/build/parsePhoneNumberWithError.js.map +1 -1
- package/build/parsePhoneNumberWithError.test.js +31 -35
- package/build/parsePhoneNumberWithError.test.js.map +1 -1
- package/build/parsePhoneNumberWithError_.js +7 -10
- package/build/parsePhoneNumberWithError_.js.map +1 -1
- package/build/parsePhoneNumber_.js +11 -16
- package/build/parsePhoneNumber_.js.map +1 -1
- package/build/searchPhoneNumbersInText.js +10 -16
- package/build/searchPhoneNumbersInText.js.map +1 -1
- package/build/searchPhoneNumbersInText.test.js +11 -21
- package/build/searchPhoneNumbersInText.test.js.map +1 -1
- package/build/tools/semver-compare.js +0 -4
- package/build/tools/semver-compare.js.map +1 -1
- package/build/tools/semver-compare.test.js +2 -4
- package/build/tools/semver-compare.test.js.map +1 -1
- package/build/validatePhoneNumberLength.js +12 -20
- package/build/validatePhoneNumberLength.js.map +1 -1
- package/build/validatePhoneNumberLength.test.js +14 -16
- package/build/validatePhoneNumberLength.test.js.map +1 -1
- package/bundle/libphonenumber-js.min.js +1 -1
- package/bundle/libphonenumber-js.min.js.map +1 -1
- package/bundle/libphonenumber-max.js +1 -1
- package/bundle/libphonenumber-max.js.map +1 -1
- package/bundle/libphonenumber-min.js +1 -1
- package/bundle/libphonenumber-min.js.map +1 -1
- package/bundle/libphonenumber-mobile.js +1 -1
- package/bundle/libphonenumber-mobile.js.map +1 -1
- package/es6/AsYouType.js +66 -112
- package/es6/AsYouType.js.map +1 -1
- package/es6/AsYouType.test.js +610 -551
- package/es6/AsYouType.test.js.map +1 -1
- package/es6/AsYouTypeFormatter.PatternMatcher.js +27 -72
- package/es6/AsYouTypeFormatter.PatternMatcher.js.map +1 -1
- package/es6/AsYouTypeFormatter.PatternMatcher.test.js +106 -106
- package/es6/AsYouTypeFormatter.PatternMatcher.test.js.map +1 -1
- package/es6/AsYouTypeFormatter.PatternParser.js +33 -64
- package/es6/AsYouTypeFormatter.PatternParser.js.map +1 -1
- package/es6/AsYouTypeFormatter.PatternParser.test.js +6 -6
- package/es6/AsYouTypeFormatter.PatternParser.test.js.map +1 -1
- package/es6/AsYouTypeFormatter.complete.js +17 -21
- package/es6/AsYouTypeFormatter.complete.js.map +1 -1
- package/es6/AsYouTypeFormatter.js +193 -217
- package/es6/AsYouTypeFormatter.js.map +1 -1
- package/es6/AsYouTypeFormatter.util.js +10 -30
- package/es6/AsYouTypeFormatter.util.js.map +1 -1
- package/es6/AsYouTypeFormatter.util.test.js +6 -6
- package/es6/AsYouTypeFormatter.util.test.js.map +1 -1
- package/es6/AsYouTypeParser.js +87 -132
- package/es6/AsYouTypeParser.js.map +1 -1
- package/es6/AsYouTypeState.js +12 -20
- package/es6/AsYouTypeState.js.map +1 -1
- package/es6/ParseError.js +21 -40
- package/es6/ParseError.js.map +1 -1
- package/es6/PhoneNumber.js +45 -68
- package/es6/PhoneNumber.js.map +1 -1
- package/es6/PhoneNumber.test.js +41 -30
- package/es6/PhoneNumber.test.js.map +1 -1
- package/es6/PhoneNumberMatcher.js +61 -78
- package/es6/PhoneNumberMatcher.js.map +1 -1
- package/es6/PhoneNumberMatcher.test.js +35 -16
- package/es6/PhoneNumberMatcher.test.js.map +1 -1
- package/es6/constants.js +15 -9
- package/es6/constants.js.map +1 -1
- package/es6/findNumbers/LRUCache.js +22 -31
- package/es6/findNumbers/LRUCache.js.map +1 -1
- package/es6/findNumbers/Leniency.js +57 -103
- package/es6/findNumbers/Leniency.js.map +1 -1
- package/es6/findNumbers/RegExpCache.js +10 -16
- package/es6/findNumbers/RegExpCache.js.map +1 -1
- package/es6/findNumbers/isValidCandidate.js +12 -13
- package/es6/findNumbers/isValidCandidate.js.map +1 -1
- package/es6/findNumbers/isValidPreCandidate.js +5 -6
- package/es6/findNumbers/isValidPreCandidate.js.map +1 -1
- package/es6/findNumbers/matchPhoneNumberStringAgainstPhoneNumber.js +9 -12
- package/es6/findNumbers/matchPhoneNumberStringAgainstPhoneNumber.js.map +1 -1
- package/es6/findNumbers/parsePreCandidate.js +3 -2
- package/es6/findNumbers/parsePreCandidate.js.map +1 -1
- package/es6/findNumbers/utf-8.js +5 -3
- package/es6/findNumbers/utf-8.js.map +1 -1
- package/es6/findNumbers/util.js +1 -4
- package/es6/findNumbers/util.js.map +1 -1
- package/es6/findNumbers/util.test.js +9 -14
- package/es6/findNumbers/util.test.js.map +1 -1
- package/es6/findPhoneNumbersInText.js +9 -12
- package/es6/findPhoneNumbersInText.js.map +1 -1
- package/es6/findPhoneNumbersInText.test.js +101 -91
- package/es6/findPhoneNumbersInText.test.js.map +1 -1
- package/es6/format.js +27 -50
- package/es6/format.js.map +1 -1
- package/es6/format.test.js +133 -116
- package/es6/format.test.js.map +1 -1
- package/es6/formatIncompletePhoneNumber.js +1 -2
- package/es6/formatIncompletePhoneNumber.js.map +1 -1
- package/es6/formatIncompletePhoneNumber.test.js +14 -10
- package/es6/formatIncompletePhoneNumber.test.js.map +1 -1
- package/es6/formatPhoneNumberForMobileDialing.js +31 -24
- package/es6/formatPhoneNumberForMobileDialing.js.map +1 -1
- package/es6/getCountries.js.map +1 -1
- package/es6/getCountries.test.js +2 -2
- package/es6/getCountries.test.js.map +1 -1
- package/es6/getCountryCallingCode.js.map +1 -1
- package/es6/getCountryCallingCode.test.js +2 -2
- package/es6/getCountryCallingCode.test.js.map +1 -1
- package/es6/getExampleNumber.js.map +1 -1
- package/es6/getExampleNumber.test.js +6 -6
- package/es6/getExampleNumber.test.js.map +1 -1
- package/es6/helpers/RFC3966.js +17 -34
- package/es6/helpers/RFC3966.js.map +1 -1
- package/es6/helpers/RFC3966.test.js +16 -13
- package/es6/helpers/RFC3966.test.js.map +1 -1
- package/es6/helpers/applyInternationalSeparatorStyle.js +3 -2
- package/es6/helpers/applyInternationalSeparatorStyle.js.map +1 -1
- package/es6/helpers/applyInternationalSeparatorStyle.test.js +2 -2
- package/es6/helpers/applyInternationalSeparatorStyle.test.js.map +1 -1
- package/es6/helpers/checkNumberLength.js +17 -17
- package/es6/helpers/checkNumberLength.js.map +1 -1
- package/es6/helpers/checkNumberLength.test.js +20 -23
- package/es6/helpers/checkNumberLength.test.js.map +1 -1
- package/es6/helpers/extension/createExtensionPattern.js +21 -34
- package/es6/helpers/extension/createExtensionPattern.js.map +1 -1
- package/es6/helpers/extension/extractExtension.js +7 -9
- package/es6/helpers/extension/extractExtension.js.map +1 -1
- package/es6/helpers/extractCountryCallingCode.js +14 -18
- package/es6/helpers/extractCountryCallingCode.js.map +1 -1
- package/es6/helpers/extractCountryCallingCode.test.js +4 -4
- package/es6/helpers/extractCountryCallingCode.test.js.map +1 -1
- package/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +4 -9
- package/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js.map +1 -1
- package/es6/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js +14 -19
- package/es6/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js.map +1 -1
- package/es6/helpers/extractNationalNumber.js +10 -15
- package/es6/helpers/extractNationalNumber.js.map +1 -1
- package/es6/helpers/extractNationalNumber.test.js +2 -4
- package/es6/helpers/extractNationalNumber.test.js.map +1 -1
- package/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +12 -17
- package/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js.map +1 -1
- package/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.test.js +2 -2
- package/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.test.js.map +1 -1
- package/es6/helpers/extractPhoneContext.js +17 -17
- package/es6/helpers/extractPhoneContext.js.map +1 -1
- package/es6/helpers/extractPhoneContext.test.js +12 -12
- package/es6/helpers/extractPhoneContext.test.js.map +1 -1
- package/es6/helpers/formatNationalNumberUsingFormat.js +8 -8
- package/es6/helpers/formatNationalNumberUsingFormat.js.map +1 -1
- package/es6/helpers/getCountryByCallingCode.js +4 -9
- package/es6/helpers/getCountryByCallingCode.js.map +1 -1
- package/es6/helpers/getCountryByNationalNumber.js +17 -15
- package/es6/helpers/getCountryByNationalNumber.js.map +1 -1
- package/es6/helpers/getIddPrefix.js +3 -4
- package/es6/helpers/getIddPrefix.js.map +1 -1
- package/es6/helpers/getNumberType.js +22 -29
- package/es6/helpers/getNumberType.js.map +1 -1
- package/es6/helpers/getNumberType.test.js +4 -4
- package/es6/helpers/getNumberType.test.js.map +1 -1
- package/es6/helpers/getPossibleCountriesForNumber.js +1 -8
- package/es6/helpers/getPossibleCountriesForNumber.js.map +1 -1
- package/es6/helpers/isObject.js.map +1 -1
- package/es6/helpers/isViablePhoneNumber.js +21 -13
- package/es6/helpers/isViablePhoneNumber.js.map +1 -1
- package/es6/helpers/matchesEntirely.js.map +1 -1
- package/es6/helpers/matchesEntirely.test.js +3 -2
- package/es6/helpers/matchesEntirely.test.js.map +1 -1
- package/es6/helpers/mergeArrays.js +6 -10
- package/es6/helpers/mergeArrays.js.map +1 -1
- package/es6/helpers/mergeArrays.test.js +1 -1
- package/es6/helpers/mergeArrays.test.js.map +1 -1
- package/es6/helpers/parseDigits.js +6 -12
- package/es6/helpers/parseDigits.js.map +1 -1
- package/es6/helpers/parseDigits.test.js +1 -1
- package/es6/helpers/parseDigits.test.js.map +1 -1
- package/es6/helpers/stripIddPrefix.js +6 -11
- package/es6/helpers/stripIddPrefix.js.map +1 -1
- package/es6/helpers/stripIddPrefix.test.js +4 -4
- package/es6/helpers/stripIddPrefix.test.js.map +1 -1
- package/es6/isPossible.js +3 -10
- package/es6/isPossible.js.map +1 -1
- package/es6/isPossible.test.js +34 -38
- package/es6/isPossible.test.js.map +1 -1
- package/es6/isPossiblePhoneNumber.js +9 -10
- package/es6/isPossiblePhoneNumber.js.map +1 -1
- package/es6/isPossiblePhoneNumber.test.js +12 -16
- package/es6/isPossiblePhoneNumber.test.js.map +1 -1
- package/es6/isValid.js +7 -6
- package/es6/isValid.js.map +1 -1
- package/es6/isValid.test.js +59 -55
- package/es6/isValid.test.js.map +1 -1
- package/es6/isValidPhoneNumber.js +9 -10
- package/es6/isValidPhoneNumber.js.map +1 -1
- package/es6/isValidPhoneNumber.test.js +10 -13
- package/es6/isValidPhoneNumber.test.js.map +1 -1
- package/es6/legacy/findNumbers.js +3 -6
- package/es6/legacy/findNumbers.js.map +1 -1
- package/es6/legacy/findNumbers.test.js +77 -60
- package/es6/legacy/findNumbers.test.js.map +1 -1
- package/es6/legacy/findPhoneNumbers.js +8 -9
- package/es6/legacy/findPhoneNumbers.js.map +1 -1
- package/es6/legacy/findPhoneNumbers.test.js +73 -62
- package/es6/legacy/findPhoneNumbers.test.js.map +1 -1
- package/es6/legacy/findPhoneNumbersInitialImplementation.js +32 -45
- package/es6/legacy/findPhoneNumbersInitialImplementation.js.map +1 -1
- package/es6/legacy/format.js +27 -37
- package/es6/legacy/format.js.map +1 -1
- package/es6/legacy/format.test.js +119 -101
- package/es6/legacy/format.test.js.map +1 -1
- package/es6/legacy/getNumberType.js +31 -37
- package/es6/legacy/getNumberType.js.map +1 -1
- package/es6/legacy/getNumberType.test.js +31 -31
- package/es6/legacy/getNumberType.test.js.map +1 -1
- package/es6/legacy/isPossibleNumber.js +5 -7
- package/es6/legacy/isPossibleNumber.js.map +1 -1
- package/es6/legacy/isPossibleNumber.test.js +22 -23
- package/es6/legacy/isPossibleNumber.test.js.map +1 -1
- package/es6/legacy/isValidNumber.js +6 -7
- package/es6/legacy/isValidNumber.js.map +1 -1
- package/es6/legacy/isValidNumber.test.js +41 -37
- package/es6/legacy/isValidNumber.test.js.map +1 -1
- package/es6/legacy/isValidNumberForRegion.js +5 -7
- package/es6/legacy/isValidNumberForRegion.js.map +1 -1
- package/es6/legacy/isValidNumberForRegion.test.js +6 -8
- package/es6/legacy/isValidNumberForRegion.test.js.map +1 -1
- package/es6/legacy/isValidNumberForRegion_.js +1 -1
- package/es6/legacy/isValidNumberForRegion_.js.map +1 -1
- package/es6/legacy/parse.js +3 -4
- package/es6/legacy/parse.js.map +1 -1
- package/es6/legacy/parse.test.js +233 -191
- package/es6/legacy/parse.test.js.map +1 -1
- package/es6/legacy/searchNumbers.js +8 -8
- package/es6/legacy/searchNumbers.js.map +1 -1
- package/es6/legacy/searchNumbers.test.js +6 -11
- package/es6/legacy/searchNumbers.test.js.map +1 -1
- package/es6/metadata.js +86 -114
- package/es6/metadata.js.map +1 -1
- package/es6/metadata.test.js +57 -73
- package/es6/metadata.test.js.map +1 -1
- package/es6/normalizeArguments.js +26 -32
- package/es6/normalizeArguments.js.map +1 -1
- package/es6/parse.js +66 -94
- package/es6/parse.js.map +1 -1
- package/es6/parse.test.js +244 -203
- package/es6/parse.test.js.map +1 -1
- package/es6/parseIncompletePhoneNumber.js +9 -16
- package/es6/parseIncompletePhoneNumber.js.map +1 -1
- package/es6/parseIncompletePhoneNumber.test.js +22 -18
- package/es6/parseIncompletePhoneNumber.test.js.map +1 -1
- package/es6/parsePhoneNumber.js +3 -4
- package/es6/parsePhoneNumber.js.map +1 -1
- package/es6/parsePhoneNumber.test.js +14 -23
- package/es6/parsePhoneNumber.test.js.map +1 -1
- package/es6/parsePhoneNumberWithError.js +3 -4
- package/es6/parsePhoneNumberWithError.js.map +1 -1
- package/es6/parsePhoneNumberWithError.test.js +32 -33
- package/es6/parsePhoneNumberWithError.test.js.map +1 -1
- package/es6/parsePhoneNumberWithError_.js +6 -6
- package/es6/parsePhoneNumberWithError_.js.map +1 -1
- package/es6/parsePhoneNumber_.js +10 -10
- package/es6/parsePhoneNumber_.js.map +1 -1
- package/es6/searchPhoneNumbersInText.js +9 -11
- package/es6/searchPhoneNumbersInText.js.map +1 -1
- package/es6/searchPhoneNumbersInText.test.js +11 -18
- package/es6/searchPhoneNumbersInText.test.js.map +1 -1
- package/es6/tools/semver-compare.js +0 -3
- package/es6/tools/semver-compare.js.map +1 -1
- package/es6/tools/semver-compare.test.js +1 -1
- package/es6/tools/semver-compare.test.js.map +1 -1
- package/es6/validatePhoneNumberLength.js +11 -12
- package/es6/validatePhoneNumberLength.js.map +1 -1
- package/es6/validatePhoneNumberLength.test.js +14 -14
- package/es6/validatePhoneNumberLength.test.js.map +1 -1
- package/jest.config.json +26 -0
- package/metadata.full.json +1 -1
- package/metadata.full.json.js +1 -1
- package/metadata.max.json +1 -1
- package/metadata.max.json.js +1 -1
- package/metadata.min.json +1 -1
- package/metadata.min.json.js +1 -1
- package/metadata.mobile.json +1 -1
- package/metadata.mobile.json.js +1 -1
- package/package.json +36 -26
- package/rollup.config.mjs +2 -2
- package/runnable/generate-country-codes.js +1 -1
- package/source/AsYouType.test.js +414 -414
- package/source/AsYouTypeFormatter.PatternMatcher.test.js +91 -91
- package/source/AsYouTypeFormatter.PatternParser.test.js +6 -6
- package/source/AsYouTypeFormatter.util.test.js +6 -6
- package/source/PhoneNumber.js +13 -15
- package/source/PhoneNumber.test.js +36 -29
- package/source/PhoneNumberMatcher.js +8 -9
- package/source/PhoneNumberMatcher.test.js +18 -6
- package/source/findNumbers/Leniency.js +0 -1
- package/source/findNumbers/util.test.js +14 -19
- package/source/findPhoneNumbersInText.test.js +98 -53
- package/source/format.test.js +70 -65
- package/source/formatIncompletePhoneNumber.test.js +11 -7
- package/source/formatPhoneNumberForMobileDialing.js +16 -1
- package/source/getCountries.test.js +2 -2
- package/source/getCountryCallingCode.test.js +2 -2
- package/source/getExampleNumber.test.js +6 -6
- package/source/helpers/RFC3966.test.js +8 -8
- package/source/helpers/applyInternationalSeparatorStyle.test.js +2 -2
- package/source/helpers/checkNumberLength.test.js +11 -11
- package/source/helpers/extractCountryCallingCode.test.js +4 -4
- package/source/helpers/extractNationalNumber.test.js +2 -2
- package/source/helpers/extractNationalNumberFromPossiblyIncompleteNumber.test.js +2 -2
- package/source/helpers/extractPhoneContext.test.js +1 -1
- package/source/helpers/getNumberType.test.js +4 -4
- package/source/helpers/matchesEntirely.test.js +2 -2
- package/source/helpers/mergeArrays.test.js +1 -1
- package/source/helpers/parseDigits.test.js +1 -1
- package/source/helpers/stripIddPrefix.test.js +4 -4
- package/source/isPossible.test.js +16 -10
- package/source/isPossiblePhoneNumber.test.js +12 -13
- package/source/isValid.test.js +20 -20
- package/source/isValidPhoneNumber.test.js +9 -9
- package/source/legacy/findNumbers.test.js +57 -44
- package/source/legacy/findPhoneNumbers.test.js +51 -35
- package/source/legacy/format.test.js +74 -71
- package/source/legacy/getNumberType.test.js +20 -18
- package/source/legacy/isPossibleNumber.test.js +16 -10
- package/source/legacy/isValidNumber.test.js +25 -23
- package/source/legacy/isValidNumberForRegion.test.js +5 -5
- package/source/legacy/parse.test.js +114 -117
- package/source/legacy/searchNumbers.test.js +3 -3
- package/source/metadata.test.js +61 -49
- package/source/parse.test.js +116 -119
- package/source/parseIncompletePhoneNumber.test.js +13 -13
- package/source/parsePhoneNumber.test.js +14 -14
- package/source/parsePhoneNumberWithError.test.js +26 -26
- package/source/searchPhoneNumbersInText.test.js +8 -8
- package/source/tools/semver-compare.test.js +1 -1
- package/source/validatePhoneNumberLength.test.js +10 -10
- package/build/findNumbers/Leniency.test.js +0 -37
- package/build/findNumbers/Leniency.test.js.map +0 -1
- package/build/formatPhoneNumberForMobileDialing.test.js +0 -15
- package/build/formatPhoneNumberForMobileDialing.test.js.map +0 -1
- package/es6/findNumbers/Leniency.test.js +0 -36
- package/es6/findNumbers/Leniency.test.js.map +0 -1
- package/es6/formatPhoneNumberForMobileDialing.test.js +0 -14
- package/es6/formatPhoneNumberForMobileDialing.test.js.map +0 -1
- package/source/findNumbers/Leniency.test.js +0 -35
- package/source/formatPhoneNumberForMobileDialing.test.js +0 -16
package/build/metadata.js
CHANGED
|
@@ -8,44 +8,39 @@ exports.getCountryCallingCode = getCountryCallingCode;
|
|
|
8
8
|
exports.getExtPrefix = getExtPrefix;
|
|
9
9
|
exports.isSupportedCountry = isSupportedCountry;
|
|
10
10
|
exports.validateMetadata = validateMetadata;
|
|
11
|
-
|
|
12
11
|
var _semverCompare = _interopRequireDefault(require("./tools/semver-compare.js"));
|
|
13
|
-
|
|
14
12
|
var _isObject = _interopRequireDefault(require("./helpers/isObject.js"));
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
25
|
-
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
14
|
+
function _readOnlyError(r) { throw new TypeError('"' + r + '" is read-only'); }
|
|
15
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
16
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
17
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
18
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
19
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
20
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
26
21
|
// Added "possibleLengths" and renamed
|
|
27
22
|
// "country_phone_code_to_countries" to "country_calling_codes".
|
|
28
|
-
var V2 = '1.0.18';
|
|
23
|
+
var V2 = '1.0.18';
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
// Added "idd_prefix" and "default_idd_prefix".
|
|
26
|
+
var V3 = '1.2.0';
|
|
31
27
|
|
|
28
|
+
// Moved `001` country code to "nonGeographic" section of metadata.
|
|
32
29
|
var V4 = '1.7.35';
|
|
33
30
|
var DEFAULT_EXT_PREFIX = ' ext. ';
|
|
34
31
|
var CALLING_CODE_REG_EXP = /^\d+$/;
|
|
32
|
+
|
|
35
33
|
/**
|
|
36
34
|
* See: https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md
|
|
37
35
|
*/
|
|
38
|
-
|
|
39
|
-
var Metadata = /*#__PURE__*/function () {
|
|
36
|
+
var Metadata = exports["default"] = /*#__PURE__*/function () {
|
|
40
37
|
function Metadata(metadata) {
|
|
41
38
|
_classCallCheck(this, Metadata);
|
|
42
|
-
|
|
43
39
|
validateMetadata(metadata);
|
|
44
40
|
this.metadata = metadata;
|
|
45
41
|
setVersion.call(this, metadata);
|
|
46
42
|
}
|
|
47
|
-
|
|
48
|
-
_createClass(Metadata, [{
|
|
43
|
+
return _createClass(Metadata, [{
|
|
49
44
|
key: "getCountries",
|
|
50
45
|
value: function getCountries() {
|
|
51
46
|
return Object.keys(this.metadata.countries).filter(function (_) {
|
|
@@ -60,10 +55,10 @@ var Metadata = /*#__PURE__*/function () {
|
|
|
60
55
|
}, {
|
|
61
56
|
key: "nonGeographic",
|
|
62
57
|
value: function nonGeographic() {
|
|
63
|
-
if (this.v1 || this.v2 || this.v3) return;
|
|
58
|
+
if (this.v1 || this.v2 || this.v3) return;
|
|
59
|
+
// `nonGeographical` was a typo.
|
|
64
60
|
// It's present in metadata generated from `1.7.35` to `1.7.37`.
|
|
65
61
|
// The test case could be found by searching for "nonGeographical".
|
|
66
|
-
|
|
67
62
|
return this.metadata.nonGeographic || this.metadata.nonGeographical;
|
|
68
63
|
}
|
|
69
64
|
}, {
|
|
@@ -77,7 +72,6 @@ var Metadata = /*#__PURE__*/function () {
|
|
|
77
72
|
if (this.getCountryCodesForCallingCode(callingCode)) {
|
|
78
73
|
return true;
|
|
79
74
|
}
|
|
80
|
-
|
|
81
75
|
if (this.nonGeographic()) {
|
|
82
76
|
if (this.nonGeographic()[callingCode]) {
|
|
83
77
|
return true;
|
|
@@ -85,7 +79,6 @@ var Metadata = /*#__PURE__*/function () {
|
|
|
85
79
|
} else {
|
|
86
80
|
// A hacky workaround for old custom metadata (generated before V4).
|
|
87
81
|
var countryCodes = this.countryCallingCodes()[callingCode];
|
|
88
|
-
|
|
89
82
|
if (countryCodes && countryCodes.length === 1 && countryCodes[0] === '001') {
|
|
90
83
|
return true;
|
|
91
84
|
}
|
|
@@ -99,8 +92,9 @@ var Metadata = /*#__PURE__*/function () {
|
|
|
99
92
|
} else {
|
|
100
93
|
return this.getCountryCodesForCallingCode(callingCode) ? false : true;
|
|
101
94
|
}
|
|
102
|
-
}
|
|
95
|
+
}
|
|
103
96
|
|
|
97
|
+
// Deprecated.
|
|
104
98
|
}, {
|
|
105
99
|
key: "country",
|
|
106
100
|
value: function country(countryCode) {
|
|
@@ -114,30 +108,25 @@ var Metadata = /*#__PURE__*/function () {
|
|
|
114
108
|
callingCode = countryCode;
|
|
115
109
|
countryCode = null;
|
|
116
110
|
}
|
|
117
|
-
|
|
118
111
|
if (countryCode && countryCode !== '001') {
|
|
119
112
|
if (!this.hasCountry(countryCode)) {
|
|
120
113
|
throw new Error("Unknown country: ".concat(countryCode));
|
|
121
114
|
}
|
|
122
|
-
|
|
123
115
|
this.numberingPlan = new NumberingPlan(this.getCountryMetadata(countryCode), this);
|
|
124
116
|
} else if (callingCode) {
|
|
125
117
|
if (!this.hasCallingCode(callingCode)) {
|
|
126
118
|
throw new Error("Unknown calling code: ".concat(callingCode));
|
|
127
119
|
}
|
|
128
|
-
|
|
129
120
|
this.numberingPlan = new NumberingPlan(this.getNumberingPlanMetadata(callingCode), this);
|
|
130
121
|
} else {
|
|
131
122
|
this.numberingPlan = undefined;
|
|
132
123
|
}
|
|
133
|
-
|
|
134
124
|
return this;
|
|
135
125
|
}
|
|
136
126
|
}, {
|
|
137
127
|
key: "getCountryCodesForCallingCode",
|
|
138
128
|
value: function getCountryCodesForCallingCode(callingCode) {
|
|
139
129
|
var countryCodes = this.countryCallingCodes()[callingCode];
|
|
140
|
-
|
|
141
130
|
if (countryCodes) {
|
|
142
131
|
// Metadata before V4 included "non-geographic entity" calling codes
|
|
143
132
|
// inside `country_calling_codes` (for example, `"881":["001"]`).
|
|
@@ -151,7 +140,6 @@ var Metadata = /*#__PURE__*/function () {
|
|
|
151
140
|
if (countryCodes.length === 1 && countryCodes[0].length === 3) {
|
|
152
141
|
return;
|
|
153
142
|
}
|
|
154
|
-
|
|
155
143
|
return countryCodes;
|
|
156
144
|
}
|
|
157
145
|
}
|
|
@@ -159,7 +147,6 @@ var Metadata = /*#__PURE__*/function () {
|
|
|
159
147
|
key: "getCountryCodeForCallingCode",
|
|
160
148
|
value: function getCountryCodeForCallingCode(callingCode) {
|
|
161
149
|
var countryCodes = this.getCountryCodesForCallingCode(callingCode);
|
|
162
|
-
|
|
163
150
|
if (countryCodes) {
|
|
164
151
|
return countryCodes[0];
|
|
165
152
|
}
|
|
@@ -168,14 +155,11 @@ var Metadata = /*#__PURE__*/function () {
|
|
|
168
155
|
key: "getNumberingPlanMetadata",
|
|
169
156
|
value: function getNumberingPlanMetadata(callingCode) {
|
|
170
157
|
var countryCode = this.getCountryCodeForCallingCode(callingCode);
|
|
171
|
-
|
|
172
158
|
if (countryCode) {
|
|
173
159
|
return this.getCountryMetadata(countryCode);
|
|
174
160
|
}
|
|
175
|
-
|
|
176
161
|
if (this.nonGeographic()) {
|
|
177
162
|
var metadata = this.nonGeographic()[callingCode];
|
|
178
|
-
|
|
179
163
|
if (metadata) {
|
|
180
164
|
return metadata;
|
|
181
165
|
}
|
|
@@ -186,79 +170,90 @@ var Metadata = /*#__PURE__*/function () {
|
|
|
186
170
|
// The test case can be found by searching for:
|
|
187
171
|
// "should work around `nonGeographic` metadata not existing".
|
|
188
172
|
var countryCodes = this.countryCallingCodes()[callingCode];
|
|
189
|
-
|
|
190
173
|
if (countryCodes && countryCodes.length === 1 && countryCodes[0] === '001') {
|
|
191
174
|
return this.metadata.countries['001'];
|
|
192
175
|
}
|
|
193
176
|
}
|
|
194
|
-
}
|
|
177
|
+
}
|
|
195
178
|
|
|
179
|
+
// Deprecated.
|
|
196
180
|
}, {
|
|
197
181
|
key: "countryCallingCode",
|
|
198
182
|
value: function countryCallingCode() {
|
|
199
183
|
return this.numberingPlan.callingCode();
|
|
200
|
-
}
|
|
184
|
+
}
|
|
201
185
|
|
|
186
|
+
// Deprecated.
|
|
202
187
|
}, {
|
|
203
188
|
key: "IDDPrefix",
|
|
204
189
|
value: function IDDPrefix() {
|
|
205
190
|
return this.numberingPlan.IDDPrefix();
|
|
206
|
-
}
|
|
191
|
+
}
|
|
207
192
|
|
|
193
|
+
// Deprecated.
|
|
208
194
|
}, {
|
|
209
195
|
key: "defaultIDDPrefix",
|
|
210
196
|
value: function defaultIDDPrefix() {
|
|
211
197
|
return this.numberingPlan.defaultIDDPrefix();
|
|
212
|
-
}
|
|
198
|
+
}
|
|
213
199
|
|
|
200
|
+
// Deprecated.
|
|
214
201
|
}, {
|
|
215
202
|
key: "nationalNumberPattern",
|
|
216
203
|
value: function nationalNumberPattern() {
|
|
217
204
|
return this.numberingPlan.nationalNumberPattern();
|
|
218
|
-
}
|
|
205
|
+
}
|
|
219
206
|
|
|
207
|
+
// Deprecated.
|
|
220
208
|
}, {
|
|
221
209
|
key: "possibleLengths",
|
|
222
210
|
value: function possibleLengths() {
|
|
223
211
|
return this.numberingPlan.possibleLengths();
|
|
224
|
-
}
|
|
212
|
+
}
|
|
225
213
|
|
|
214
|
+
// Deprecated.
|
|
226
215
|
}, {
|
|
227
216
|
key: "formats",
|
|
228
217
|
value: function formats() {
|
|
229
218
|
return this.numberingPlan.formats();
|
|
230
|
-
}
|
|
219
|
+
}
|
|
231
220
|
|
|
221
|
+
// Deprecated.
|
|
232
222
|
}, {
|
|
233
223
|
key: "nationalPrefixForParsing",
|
|
234
224
|
value: function nationalPrefixForParsing() {
|
|
235
225
|
return this.numberingPlan.nationalPrefixForParsing();
|
|
236
|
-
}
|
|
226
|
+
}
|
|
237
227
|
|
|
228
|
+
// Deprecated.
|
|
238
229
|
}, {
|
|
239
230
|
key: "nationalPrefixTransformRule",
|
|
240
231
|
value: function nationalPrefixTransformRule() {
|
|
241
232
|
return this.numberingPlan.nationalPrefixTransformRule();
|
|
242
|
-
}
|
|
233
|
+
}
|
|
243
234
|
|
|
235
|
+
// Deprecated.
|
|
244
236
|
}, {
|
|
245
237
|
key: "leadingDigits",
|
|
246
238
|
value: function leadingDigits() {
|
|
247
239
|
return this.numberingPlan.leadingDigits();
|
|
248
|
-
}
|
|
240
|
+
}
|
|
249
241
|
|
|
242
|
+
// Deprecated.
|
|
250
243
|
}, {
|
|
251
244
|
key: "hasTypes",
|
|
252
245
|
value: function hasTypes() {
|
|
253
246
|
return this.numberingPlan.hasTypes();
|
|
254
|
-
}
|
|
247
|
+
}
|
|
255
248
|
|
|
249
|
+
// Deprecated.
|
|
256
250
|
}, {
|
|
257
251
|
key: "type",
|
|
258
252
|
value: function type(_type) {
|
|
259
253
|
return this.numberingPlan.type(_type);
|
|
260
|
-
}
|
|
254
|
+
}
|
|
261
255
|
|
|
256
|
+
// Deprecated.
|
|
262
257
|
}, {
|
|
263
258
|
key: "ext",
|
|
264
259
|
value: function ext() {
|
|
@@ -269,8 +264,9 @@ var Metadata = /*#__PURE__*/function () {
|
|
|
269
264
|
value: function countryCallingCodes() {
|
|
270
265
|
if (this.v1) return this.metadata.country_phone_code_to_countries;
|
|
271
266
|
return this.metadata.country_calling_codes;
|
|
272
|
-
}
|
|
267
|
+
}
|
|
273
268
|
|
|
269
|
+
// Deprecated.
|
|
274
270
|
}, {
|
|
275
271
|
key: "chooseCountryByCountryCallingCode",
|
|
276
272
|
value: function chooseCountryByCountryCallingCode(callingCode) {
|
|
@@ -282,45 +278,41 @@ var Metadata = /*#__PURE__*/function () {
|
|
|
282
278
|
return this.numberingPlan !== undefined;
|
|
283
279
|
}
|
|
284
280
|
}]);
|
|
285
|
-
|
|
286
|
-
return Metadata;
|
|
287
281
|
}();
|
|
288
|
-
|
|
289
|
-
exports["default"] = Metadata;
|
|
290
|
-
|
|
291
282
|
var NumberingPlan = /*#__PURE__*/function () {
|
|
292
283
|
function NumberingPlan(metadata, globalMetadataObject) {
|
|
293
284
|
_classCallCheck(this, NumberingPlan);
|
|
294
|
-
|
|
295
285
|
this.globalMetadataObject = globalMetadataObject;
|
|
296
286
|
this.metadata = metadata;
|
|
297
287
|
setVersion.call(this, globalMetadataObject.metadata);
|
|
298
288
|
}
|
|
299
|
-
|
|
300
|
-
_createClass(NumberingPlan, [{
|
|
289
|
+
return _createClass(NumberingPlan, [{
|
|
301
290
|
key: "callingCode",
|
|
302
291
|
value: function callingCode() {
|
|
303
292
|
return this.metadata[0];
|
|
304
|
-
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Formatting information for regions which share
|
|
305
296
|
// a country calling code is contained by only one region
|
|
306
297
|
// for performance reasons. For example, for NANPA region
|
|
307
298
|
// ("North American Numbering Plan Administration",
|
|
308
299
|
// which includes USA, Canada, Cayman Islands, Bahamas, etc)
|
|
309
300
|
// it will be contained in the metadata for `US`.
|
|
310
|
-
|
|
311
301
|
}, {
|
|
312
302
|
key: "getDefaultCountryMetadataForRegion",
|
|
313
303
|
value: function getDefaultCountryMetadataForRegion() {
|
|
314
304
|
return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode());
|
|
315
|
-
}
|
|
305
|
+
}
|
|
316
306
|
|
|
307
|
+
// Is always present.
|
|
317
308
|
}, {
|
|
318
309
|
key: "IDDPrefix",
|
|
319
310
|
value: function IDDPrefix() {
|
|
320
311
|
if (this.v1 || this.v2) return;
|
|
321
312
|
return this.metadata[1];
|
|
322
|
-
}
|
|
313
|
+
}
|
|
323
314
|
|
|
315
|
+
// Is only present when a country supports multiple IDD prefixes.
|
|
324
316
|
}, {
|
|
325
317
|
key: "defaultIDDPrefix",
|
|
326
318
|
value: function defaultIDDPrefix() {
|
|
@@ -332,8 +324,9 @@ var NumberingPlan = /*#__PURE__*/function () {
|
|
|
332
324
|
value: function nationalNumberPattern() {
|
|
333
325
|
if (this.v1 || this.v2) return this.metadata[1];
|
|
334
326
|
return this.metadata[2];
|
|
335
|
-
}
|
|
327
|
+
}
|
|
336
328
|
|
|
329
|
+
// "possible length" data is always present in Google's metadata.
|
|
337
330
|
}, {
|
|
338
331
|
key: "possibleLengths",
|
|
339
332
|
value: function possibleLengths() {
|
|
@@ -344,15 +337,15 @@ var NumberingPlan = /*#__PURE__*/function () {
|
|
|
344
337
|
key: "_getFormats",
|
|
345
338
|
value: function _getFormats(metadata) {
|
|
346
339
|
return metadata[this.v1 ? 2 : this.v2 ? 3 : 4];
|
|
347
|
-
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// For countries of the same region (e.g. NANPA)
|
|
348
343
|
// formats are all stored in the "main" country for that region.
|
|
349
344
|
// E.g. "RU" and "KZ", "US" and "CA".
|
|
350
|
-
|
|
351
345
|
}, {
|
|
352
346
|
key: "formats",
|
|
353
347
|
value: function formats() {
|
|
354
348
|
var _this = this;
|
|
355
|
-
|
|
356
349
|
var formats = this._getFormats(this.metadata) || this._getFormats(this.getDefaultCountryMetadataForRegion()) || [];
|
|
357
350
|
return formats.map(function (_) {
|
|
358
351
|
return new Format(_, _this);
|
|
@@ -367,10 +360,11 @@ var NumberingPlan = /*#__PURE__*/function () {
|
|
|
367
360
|
key: "_getNationalPrefixFormattingRule",
|
|
368
361
|
value: function _getNationalPrefixFormattingRule(metadata) {
|
|
369
362
|
return metadata[this.v1 ? 4 : this.v2 ? 5 : 6];
|
|
370
|
-
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// For countries of the same region (e.g. NANPA)
|
|
371
366
|
// national prefix formatting rule is stored in the "main" country for that region.
|
|
372
367
|
// E.g. "RU" and "KZ", "US" and "CA".
|
|
373
|
-
|
|
374
368
|
}, {
|
|
375
369
|
key: "nationalPrefixFormattingRule",
|
|
376
370
|
value: function nationalPrefixFormattingRule() {
|
|
@@ -397,11 +391,12 @@ var NumberingPlan = /*#__PURE__*/function () {
|
|
|
397
391
|
key: "_getNationalPrefixIsOptionalWhenFormatting",
|
|
398
392
|
value: function _getNationalPrefixIsOptionalWhenFormatting() {
|
|
399
393
|
return !!this.metadata[this.v1 ? 7 : this.v2 ? 8 : 9];
|
|
400
|
-
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// For countries of the same region (e.g. NANPA)
|
|
401
397
|
// "national prefix is optional when formatting" flag is
|
|
402
398
|
// stored in the "main" country for that region.
|
|
403
399
|
// E.g. "RU" and "KZ", "US" and "CA".
|
|
404
|
-
|
|
405
400
|
}, {
|
|
406
401
|
key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
|
|
407
402
|
value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
|
|
@@ -421,14 +416,12 @@ var NumberingPlan = /*#__PURE__*/function () {
|
|
|
421
416
|
key: "hasTypes",
|
|
422
417
|
value: function hasTypes() {
|
|
423
418
|
// Versions 1.2.0 - 1.2.4: can be `[]`.
|
|
424
|
-
|
|
425
419
|
/* istanbul ignore next */
|
|
426
420
|
if (this.types() && this.types().length === 0) {
|
|
427
421
|
return false;
|
|
428
|
-
}
|
|
422
|
+
}
|
|
423
|
+
// Versions <= 1.2.4: can be `undefined`.
|
|
429
424
|
// Version >= 1.2.5: can be `0`.
|
|
430
|
-
|
|
431
|
-
|
|
432
425
|
return !!this.types();
|
|
433
426
|
}
|
|
434
427
|
}, {
|
|
@@ -445,19 +438,14 @@ var NumberingPlan = /*#__PURE__*/function () {
|
|
|
445
438
|
return this.metadata[13] || DEFAULT_EXT_PREFIX;
|
|
446
439
|
}
|
|
447
440
|
}]);
|
|
448
|
-
|
|
449
|
-
return NumberingPlan;
|
|
450
441
|
}();
|
|
451
|
-
|
|
452
442
|
var Format = /*#__PURE__*/function () {
|
|
453
443
|
function Format(format, metadata) {
|
|
454
444
|
_classCallCheck(this, Format);
|
|
455
|
-
|
|
456
445
|
this._format = format;
|
|
457
446
|
this.metadata = metadata;
|
|
458
447
|
}
|
|
459
|
-
|
|
460
|
-
_createClass(Format, [{
|
|
448
|
+
return _createClass(Format, [{
|
|
461
449
|
key: "pattern",
|
|
462
450
|
value: function pattern() {
|
|
463
451
|
return this._format[0];
|
|
@@ -491,13 +479,16 @@ var Format = /*#__PURE__*/function () {
|
|
|
491
479
|
// national prefix is optional for this phone number format
|
|
492
480
|
// (and it is not enforced explicitly)
|
|
493
481
|
return this.usesNationalPrefix() && !this.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
|
|
494
|
-
}
|
|
482
|
+
}
|
|
495
483
|
|
|
484
|
+
// Checks whether national prefix formatting rule contains national prefix.
|
|
496
485
|
}, {
|
|
497
486
|
key: "usesNationalPrefix",
|
|
498
487
|
value: function usesNationalPrefix() {
|
|
499
|
-
return this.nationalPrefixFormattingRule() &&
|
|
500
|
-
|
|
488
|
+
return this.nationalPrefixFormattingRule() &&
|
|
489
|
+
// Check that national prefix formatting rule is not a "dummy" one.
|
|
490
|
+
!FIRST_GROUP_ONLY_PREFIX_PATTERN.test(this.nationalPrefixFormattingRule())
|
|
491
|
+
// In compressed metadata, `this.nationalPrefixFormattingRule()` is `0`
|
|
501
492
|
// when `national_prefix_formatting_rule` is not present.
|
|
502
493
|
// So, `true` or `false` are returned explicitly here, so that
|
|
503
494
|
// `0` number isn't returned.
|
|
@@ -509,27 +500,20 @@ var Format = /*#__PURE__*/function () {
|
|
|
509
500
|
return this._format[5] || this.format();
|
|
510
501
|
}
|
|
511
502
|
}]);
|
|
512
|
-
|
|
513
|
-
return Format;
|
|
514
503
|
}();
|
|
515
504
|
/**
|
|
516
505
|
* A pattern that is used to determine if the national prefix formatting rule
|
|
517
506
|
* has the first group only, i.e., does not start with the national prefix.
|
|
518
507
|
* Note that the pattern explicitly allows for unbalanced parentheses.
|
|
519
508
|
*/
|
|
520
|
-
|
|
521
|
-
|
|
522
509
|
var FIRST_GROUP_ONLY_PREFIX_PATTERN = /^\(?\$1\)?$/;
|
|
523
|
-
|
|
524
510
|
var Type = /*#__PURE__*/function () {
|
|
525
511
|
function Type(type, metadata) {
|
|
526
512
|
_classCallCheck(this, Type);
|
|
527
|
-
|
|
528
513
|
this.type = type;
|
|
529
514
|
this.metadata = metadata;
|
|
530
515
|
}
|
|
531
|
-
|
|
532
|
-
_createClass(Type, [{
|
|
516
|
+
return _createClass(Type, [{
|
|
533
517
|
key: "pattern",
|
|
534
518
|
value: function pattern() {
|
|
535
519
|
if (this.metadata.v1) return this.type;
|
|
@@ -542,64 +526,51 @@ var Type = /*#__PURE__*/function () {
|
|
|
542
526
|
return this.type[1] || this.metadata.possibleLengths();
|
|
543
527
|
}
|
|
544
528
|
}]);
|
|
545
|
-
|
|
546
|
-
return Type;
|
|
547
529
|
}();
|
|
548
|
-
|
|
549
530
|
function getType(types, type) {
|
|
550
531
|
switch (type) {
|
|
551
532
|
case 'FIXED_LINE':
|
|
552
533
|
return types[0];
|
|
553
|
-
|
|
554
534
|
case 'MOBILE':
|
|
555
535
|
return types[1];
|
|
556
|
-
|
|
557
536
|
case 'TOLL_FREE':
|
|
558
537
|
return types[2];
|
|
559
|
-
|
|
560
538
|
case 'PREMIUM_RATE':
|
|
561
539
|
return types[3];
|
|
562
|
-
|
|
563
540
|
case 'PERSONAL_NUMBER':
|
|
564
541
|
return types[4];
|
|
565
|
-
|
|
566
542
|
case 'VOICEMAIL':
|
|
567
543
|
return types[5];
|
|
568
|
-
|
|
569
544
|
case 'UAN':
|
|
570
545
|
return types[6];
|
|
571
|
-
|
|
572
546
|
case 'PAGER':
|
|
573
547
|
return types[7];
|
|
574
|
-
|
|
575
548
|
case 'VOIP':
|
|
576
549
|
return types[8];
|
|
577
|
-
|
|
578
550
|
case 'SHARED_COST':
|
|
579
551
|
return types[9];
|
|
580
552
|
}
|
|
581
553
|
}
|
|
582
|
-
|
|
583
554
|
function validateMetadata(metadata) {
|
|
584
555
|
if (!metadata) {
|
|
585
556
|
throw new Error('[libphonenumber-js] `metadata` argument not passed. Check your arguments.');
|
|
586
|
-
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// `country_phone_code_to_countries` was renamed to `country_calling_codes` in `1.0.18`.
|
|
587
560
|
// For that reason, it's not used in this detection algorithm.
|
|
588
561
|
// Instead, it detects by `countries: {}` property existence.
|
|
589
|
-
|
|
590
|
-
|
|
591
562
|
if (!(0, _isObject["default"])(metadata) || !(0, _isObject["default"])(metadata.countries)) {
|
|
592
563
|
throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat((0, _isObject["default"])(metadata) ? 'an object of shape: { ' + Object.keys(metadata).join(', ') + ' }' : 'a ' + typeOf(metadata) + ': ' + metadata, "."));
|
|
593
564
|
}
|
|
594
|
-
}
|
|
595
|
-
// so istanbul will show this as "branch not covered".
|
|
565
|
+
}
|
|
596
566
|
|
|
567
|
+
// Babel transforms `typeof` into some "branches"
|
|
568
|
+
// so istanbul will show this as "branch not covered".
|
|
597
569
|
/* istanbul ignore next */
|
|
598
|
-
|
|
599
|
-
|
|
600
570
|
var typeOf = function typeOf(_) {
|
|
601
571
|
return _typeof(_);
|
|
602
572
|
};
|
|
573
|
+
|
|
603
574
|
/**
|
|
604
575
|
* Returns extension prefix for a country.
|
|
605
576
|
* @param {string} country
|
|
@@ -609,17 +580,14 @@ var typeOf = function typeOf(_) {
|
|
|
609
580
|
* // Returns " ext. "
|
|
610
581
|
* getExtPrefix("US")
|
|
611
582
|
*/
|
|
612
|
-
|
|
613
|
-
|
|
614
583
|
function getExtPrefix(country, metadata) {
|
|
615
584
|
metadata = new Metadata(metadata);
|
|
616
|
-
|
|
617
585
|
if (metadata.hasCountry(country)) {
|
|
618
586
|
return metadata.country(country).ext();
|
|
619
587
|
}
|
|
620
|
-
|
|
621
588
|
return DEFAULT_EXT_PREFIX;
|
|
622
589
|
}
|
|
590
|
+
|
|
623
591
|
/**
|
|
624
592
|
* Returns "country calling code" for a country.
|
|
625
593
|
* Throws an error if the country doesn't exist or isn't supported by this library.
|
|
@@ -630,27 +598,20 @@ function getExtPrefix(country, metadata) {
|
|
|
630
598
|
* // Returns "44"
|
|
631
599
|
* getCountryCallingCode("GB")
|
|
632
600
|
*/
|
|
633
|
-
|
|
634
|
-
|
|
635
601
|
function getCountryCallingCode(country, metadata) {
|
|
636
602
|
metadata = new Metadata(metadata);
|
|
637
|
-
|
|
638
603
|
if (metadata.hasCountry(country)) {
|
|
639
604
|
return metadata.country(country).countryCallingCode();
|
|
640
605
|
}
|
|
641
|
-
|
|
642
606
|
throw new Error("Unknown country: ".concat(country));
|
|
643
607
|
}
|
|
644
|
-
|
|
645
608
|
function isSupportedCountry(country, metadata) {
|
|
646
609
|
// metadata = new Metadata(metadata)
|
|
647
610
|
// return metadata.hasCountry(country)
|
|
648
611
|
return metadata.countries.hasOwnProperty(country);
|
|
649
612
|
}
|
|
650
|
-
|
|
651
613
|
function setVersion(metadata) {
|
|
652
614
|
var version = metadata.version;
|
|
653
|
-
|
|
654
615
|
if (typeof version === 'number') {
|
|
655
616
|
this.v1 = version === 1;
|
|
656
617
|
this.v2 = version === 2;
|
|
@@ -667,7 +628,9 @@ function setVersion(metadata) {
|
|
|
667
628
|
this.v4 = true;
|
|
668
629
|
}
|
|
669
630
|
}
|
|
670
|
-
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// const ISO_COUNTRY_CODE = /^[A-Z]{2}$/
|
|
671
634
|
// function isCountryCode(countryCode) {
|
|
672
635
|
// return ISO_COUNTRY_CODE.test(countryCodeOrCountryCallingCode)
|
|
673
636
|
// }
|