libphonenumber-js 1.12.43 → 1.13.1
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/CHANGELOG.md +131 -104
- package/README.md +141 -81
- package/core/es6/index.d.cts +2 -0
- package/core/es6/index.d.ts +2 -0
- package/core/es6/index.js +39 -0
- package/core/es6/package.json +12 -0
- package/core/index.cjs +5 -0
- package/core/index.cjs.js +5 -0
- package/core/index.d.cts +3 -1
- package/core/index.d.ts +3 -1
- package/core/index.js +5 -0
- package/custom.d.ts +6 -4
- package/custom.js +5 -5
- package/es6-modern/AsYouType.js +445 -0
- package/es6-modern/AsYouType.js.map +1 -0
- package/es6-modern/AsYouType.test.js.map +1 -0
- package/es6-modern/AsYouTypeFormatter.PatternMatcher.js +195 -0
- package/es6-modern/AsYouTypeFormatter.PatternMatcher.js.map +1 -0
- package/es6-modern/AsYouTypeFormatter.PatternMatcher.test.js.map +1 -0
- package/es6-modern/AsYouTypeFormatter.PatternParser.js +184 -0
- package/es6-modern/AsYouTypeFormatter.PatternParser.js.map +1 -0
- package/es6-modern/AsYouTypeFormatter.PatternParser.test.js.map +1 -0
- package/es6-modern/AsYouTypeFormatter.complete.js +120 -0
- package/es6-modern/AsYouTypeFormatter.complete.js.map +1 -0
- package/es6-modern/AsYouTypeFormatter.js +659 -0
- package/es6-modern/AsYouTypeFormatter.js.map +1 -0
- package/es6-modern/AsYouTypeFormatter.util.js +96 -0
- package/es6-modern/AsYouTypeFormatter.util.js.map +1 -0
- package/es6-modern/AsYouTypeFormatter.util.test.js.map +1 -0
- package/es6-modern/AsYouTypeParser.js +435 -0
- package/es6-modern/AsYouTypeParser.js.map +1 -0
- package/es6-modern/AsYouTypeState.js +104 -0
- package/es6-modern/AsYouTypeState.js.map +1 -0
- package/es6-modern/ParseError.js +15 -0
- package/es6-modern/ParseError.js.map +1 -0
- package/es6-modern/PhoneNumber.js +166 -0
- package/es6-modern/PhoneNumber.js.map +1 -0
- package/es6-modern/PhoneNumber.test.js.map +1 -0
- package/es6-modern/PhoneNumberMatcher.js +330 -0
- package/es6-modern/PhoneNumberMatcher.js.map +1 -0
- package/es6-modern/PhoneNumberMatcher.test.js.map +1 -0
- package/es6-modern/constants.js +31 -0
- package/es6-modern/constants.js.map +1 -0
- package/es6-modern/findNumbers/LRUCache.js +98 -0
- package/es6-modern/findNumbers/LRUCache.js.map +1 -0
- package/es6-modern/findNumbers/Leniency.js +311 -0
- package/es6-modern/findNumbers/Leniency.js.map +1 -0
- package/es6-modern/findNumbers/RegExpCache.js +20 -0
- package/es6-modern/findNumbers/RegExpCache.js.map +1 -0
- package/es6-modern/findNumbers/isValidCandidate.js +66 -0
- package/es6-modern/findNumbers/isValidCandidate.js.map +1 -0
- package/es6-modern/findNumbers/isValidPreCandidate.js +26 -0
- package/es6-modern/findNumbers/isValidPreCandidate.js.map +1 -0
- package/es6-modern/findNumbers/matchPhoneNumberStringAgainstPhoneNumber.js +63 -0
- package/es6-modern/findNumbers/matchPhoneNumberStringAgainstPhoneNumber.js.map +1 -0
- package/es6-modern/findNumbers/parsePreCandidate.js +18 -0
- package/es6-modern/findNumbers/parsePreCandidate.js.map +1 -0
- package/es6-modern/findNumbers/utf-8.js +63 -0
- package/es6-modern/findNumbers/utf-8.js.map +1 -0
- package/es6-modern/findNumbers/util.js +26 -0
- package/es6-modern/findNumbers/util.js.map +1 -0
- package/es6-modern/findNumbers/util.test.js.map +1 -0
- package/es6-modern/findPhoneNumbersInText.js +19 -0
- package/es6-modern/findPhoneNumbersInText.js.map +1 -0
- package/es6-modern/findPhoneNumbersInText.test.js.map +1 -0
- package/es6-modern/format.js +204 -0
- package/es6-modern/format.js.map +1 -0
- package/es6-modern/format.test.js.map +1 -0
- package/es6-modern/formatIncompletePhoneNumber.js +18 -0
- package/es6-modern/formatIncompletePhoneNumber.js.map +1 -0
- package/es6-modern/formatIncompletePhoneNumber.test.js.map +1 -0
- package/es6-modern/formatPhoneNumberForMobileDialing.js +190 -0
- package/es6-modern/formatPhoneNumberForMobileDialing.js.map +1 -0
- package/es6-modern/getCountries.js +5 -0
- package/es6-modern/getCountries.js.map +1 -0
- package/es6-modern/getCountries.test.js.map +1 -0
- package/es6-modern/getCountryCallingCode.js +3 -0
- package/es6-modern/getCountryCallingCode.js.map +1 -0
- package/es6-modern/getCountryCallingCode.test.js.map +1 -0
- package/es6-modern/getExampleNumber.js +7 -0
- package/es6-modern/getExampleNumber.js.map +1 -0
- package/es6-modern/getExampleNumber.test.js.map +1 -0
- package/es6-modern/helpers/RFC3966.js +63 -0
- package/es6-modern/helpers/RFC3966.js.map +1 -0
- package/es6-modern/helpers/RFC3966.test.js.map +1 -0
- package/es6-modern/helpers/applyInternationalSeparatorStyle.js +36 -0
- package/es6-modern/helpers/applyInternationalSeparatorStyle.js.map +1 -0
- package/es6-modern/helpers/applyInternationalSeparatorStyle.test.js.map +1 -0
- package/es6-modern/helpers/checkNumberLength.js +112 -0
- package/es6-modern/helpers/checkNumberLength.js.map +1 -0
- package/es6-modern/helpers/checkNumberLength.test.js.map +1 -0
- package/es6-modern/helpers/extension/createExtensionPattern.js +93 -0
- package/es6-modern/helpers/extension/createExtensionPattern.js.map +1 -0
- package/es6-modern/helpers/extension/extractExtension.js +30 -0
- package/es6-modern/helpers/extension/extractExtension.js.map +1 -0
- package/es6-modern/helpers/extractCountryCallingCode.js +142 -0
- package/es6-modern/helpers/extractCountryCallingCode.js.map +1 -0
- package/es6-modern/helpers/extractCountryCallingCode.test.js.map +1 -0
- package/es6-modern/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +49 -0
- package/es6-modern/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js.map +1 -0
- package/es6-modern/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js +66 -0
- package/es6-modern/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js.map +1 -0
- package/es6-modern/helpers/extractNationalNumber.js +117 -0
- package/es6-modern/helpers/extractNationalNumber.js.map +1 -0
- package/es6-modern/helpers/extractNationalNumber.test.js.map +1 -0
- package/es6-modern/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +102 -0
- package/es6-modern/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js.map +1 -0
- package/es6-modern/helpers/extractNationalNumberFromPossiblyIncompleteNumber.test.js.map +1 -0
- package/es6-modern/helpers/extractPhoneContext.js +82 -0
- package/es6-modern/helpers/extractPhoneContext.js.map +1 -0
- package/es6-modern/helpers/extractPhoneContext.test.js.map +1 -0
- package/es6-modern/helpers/formatNationalNumberUsingFormat.js +34 -0
- package/es6-modern/helpers/formatNationalNumberUsingFormat.js.map +1 -0
- package/es6-modern/helpers/getCountryByCallingCode.js +30 -0
- package/es6-modern/helpers/getCountryByCallingCode.js.map +1 -0
- package/es6-modern/helpers/getCountryByNationalNumber.js +76 -0
- package/es6-modern/helpers/getCountryByNationalNumber.js.map +1 -0
- package/es6-modern/helpers/getIddPrefix.js +26 -0
- package/es6-modern/helpers/getIddPrefix.js.map +1 -0
- package/es6-modern/helpers/getNumberType.js +81 -0
- package/es6-modern/helpers/getNumberType.js.map +1 -0
- package/es6-modern/helpers/getNumberType.test.js.map +1 -0
- package/es6-modern/helpers/getPossibleCountriesForNumber.js +28 -0
- package/es6-modern/helpers/getPossibleCountriesForNumber.js.map +1 -0
- package/es6-modern/helpers/isObject.js +5 -0
- package/es6-modern/helpers/isObject.js.map +1 -0
- package/es6-modern/helpers/isViablePhoneNumber.js +77 -0
- package/es6-modern/helpers/isViablePhoneNumber.js.map +1 -0
- package/es6-modern/helpers/matchesEntirely.js +12 -0
- package/es6-modern/helpers/matchesEntirely.js.map +1 -0
- package/es6-modern/helpers/matchesEntirely.test.js.map +1 -0
- package/es6-modern/helpers/mergeArrays.js +23 -0
- package/es6-modern/helpers/mergeArrays.js.map +1 -0
- package/es6-modern/helpers/mergeArrays.test.js.map +1 -0
- package/es6-modern/helpers/parseDigits.js +111 -0
- package/es6-modern/helpers/parseDigits.js.map +1 -0
- package/es6-modern/helpers/parseDigits.test.js.map +1 -0
- package/es6-modern/helpers/stripIddPrefix.js +29 -0
- package/es6-modern/helpers/stripIddPrefix.js.map +1 -0
- package/es6-modern/helpers/stripIddPrefix.test.js.map +1 -0
- package/es6-modern/isPossible.js +77 -0
- package/es6-modern/isPossible.js.map +1 -0
- package/es6-modern/isPossible.test.js.map +1 -0
- package/es6-modern/isPossiblePhoneNumber.js +16 -0
- package/es6-modern/isPossiblePhoneNumber.js.map +1 -0
- package/es6-modern/isPossiblePhoneNumber.test.js.map +1 -0
- package/es6-modern/isValid.js +57 -0
- package/es6-modern/isValid.js.map +1 -0
- package/es6-modern/isValid.test.js.map +1 -0
- package/es6-modern/isValidPhoneNumber.js +16 -0
- package/es6-modern/isValidPhoneNumber.js.map +1 -0
- package/es6-modern/isValidPhoneNumber.test.js.map +1 -0
- package/es6-modern/legacy/PhoneNumberSearch.js +109 -0
- package/es6-modern/legacy/PhoneNumberSearch.js.map +1 -0
- package/es6-modern/legacy/findNumbers.js +16 -0
- package/es6-modern/legacy/findNumbers.js.map +1 -0
- package/es6-modern/legacy/findNumbers.test.js.map +1 -0
- package/es6-modern/legacy/findPhoneNumbers.js +26 -0
- package/es6-modern/legacy/findPhoneNumbers.js.map +1 -0
- package/es6-modern/legacy/findPhoneNumbers.test.js.map +1 -0
- package/es6-modern/legacy/findPhoneNumbersInitialImplementation.js +79 -0
- package/es6-modern/legacy/findPhoneNumbersInitialImplementation.js.map +1 -0
- package/es6-modern/legacy/format.js +97 -0
- package/es6-modern/legacy/format.js.map +1 -0
- package/es6-modern/legacy/format.test.js.map +1 -0
- package/es6-modern/legacy/getNumberType.js +104 -0
- package/es6-modern/legacy/getNumberType.js.map +1 -0
- package/es6-modern/legacy/getNumberType.test.js.map +1 -0
- package/es6-modern/legacy/isPossibleNumber.js +30 -0
- package/es6-modern/legacy/isPossibleNumber.js.map +1 -0
- package/es6-modern/legacy/isPossibleNumber.test.js.map +1 -0
- package/es6-modern/legacy/isValidNumber.js +17 -0
- package/es6-modern/legacy/isValidNumber.js.map +1 -0
- package/es6-modern/legacy/isValidNumber.test.js.map +1 -0
- package/es6-modern/legacy/isValidNumberForRegion.js +65 -0
- package/es6-modern/legacy/isValidNumberForRegion.js.map +1 -0
- package/es6-modern/legacy/isValidNumberForRegion.test.js.map +1 -0
- package/es6-modern/legacy/isValidNumberForRegion_.js +14 -0
- package/es6-modern/legacy/isValidNumberForRegion_.js.map +1 -0
- package/es6-modern/legacy/parse.js +11 -0
- package/es6-modern/legacy/parse.js.map +1 -0
- package/es6-modern/legacy/parse.test.js.map +1 -0
- package/es6-modern/legacy/searchNumbers.js +32 -0
- package/es6-modern/legacy/searchNumbers.js.map +1 -0
- package/es6-modern/legacy/searchNumbers.test.js.map +1 -0
- package/es6-modern/metadata.js +494 -0
- package/es6-modern/metadata.js.map +1 -0
- package/es6-modern/metadata.test.js.map +1 -0
- package/es6-modern/normalizeArguments.js +52 -0
- package/es6-modern/normalizeArguments.js.map +1 -0
- package/es6-modern/parse.js +341 -0
- package/es6-modern/parse.js.map +1 -0
- package/es6-modern/parse.test.js.map +1 -0
- package/es6-modern/parseIncompletePhoneNumber.js +70 -0
- package/es6-modern/parseIncompletePhoneNumber.js.map +1 -0
- package/es6-modern/parseIncompletePhoneNumber.test.js.map +1 -0
- package/es6-modern/parsePhoneNumber.js +11 -0
- package/es6-modern/parsePhoneNumber.js.map +1 -0
- package/es6-modern/parsePhoneNumber.test.js.map +1 -0
- package/es6-modern/parsePhoneNumberWithError.js +11 -0
- package/es6-modern/parsePhoneNumberWithError.js.map +1 -0
- package/es6-modern/parsePhoneNumberWithError.test.js.map +1 -0
- package/es6-modern/parsePhoneNumberWithError_.js +8 -0
- package/es6-modern/parsePhoneNumberWithError_.js.map +1 -0
- package/es6-modern/parsePhoneNumber_.js +24 -0
- package/es6-modern/parsePhoneNumber_.js.map +1 -0
- package/es6-modern/searchPhoneNumbersInText.js +31 -0
- package/es6-modern/searchPhoneNumbersInText.js.map +1 -0
- package/es6-modern/searchPhoneNumbersInText.test.js.map +1 -0
- package/es6-modern/tools/semver-compare.js +27 -0
- package/es6-modern/tools/semver-compare.js.map +1 -0
- package/es6-modern/tools/semver-compare.test.js.map +1 -0
- package/es6-modern/validatePhoneNumberLength.js +35 -0
- package/es6-modern/validatePhoneNumberLength.js.map +1 -0
- package/es6-modern/validatePhoneNumberLength.test.js.map +1 -0
- package/index.cjs +4 -0
- package/index.cjs.js +4 -0
- package/index.d.cts +5 -3
- package/index.d.ts +5 -3
- package/index.js +5 -0
- package/max/es6/exports/AsYouType.js +11 -0
- package/max/es6/exports/Metadata.js +11 -0
- package/max/es6/exports/PhoneNumber.js +11 -0
- package/max/es6/exports/PhoneNumberMatcher.js +11 -0
- package/max/es6/exports/findNumbers.js +6 -0
- package/max/es6/exports/findPhoneNumbersInText.js +6 -0
- package/max/es6/exports/formatIncompletePhoneNumber.js +6 -0
- package/max/es6/exports/getCountries.js +6 -0
- package/max/es6/exports/getCountryCallingCode.js +6 -0
- package/max/es6/exports/getExampleNumber.js +6 -0
- package/max/es6/exports/getExtPrefix.js +6 -0
- package/max/es6/exports/isPossiblePhoneNumber.js +6 -0
- package/max/es6/exports/isSupportedCountry.js +6 -0
- package/max/es6/exports/isValidPhoneNumber.js +6 -0
- package/max/es6/exports/parsePhoneNumber.js +7 -0
- package/max/es6/exports/parsePhoneNumberWithError.js +7 -0
- package/max/es6/exports/searchNumbers.js +6 -0
- package/max/es6/exports/searchPhoneNumbersInText.js +6 -0
- package/max/es6/exports/validatePhoneNumberLength.js +6 -0
- package/max/es6/exports/withMetadataArgument.js +13 -0
- package/max/es6/index.d.cts +2 -0
- package/max/es6/index.d.ts +2 -0
- package/max/es6/index.js +44 -0
- package/max/es6/package.json +12 -0
- package/max/index.cjs +5 -0
- package/max/index.cjs.js +5 -0
- package/max/index.d.cts +3 -1
- package/max/index.d.ts +3 -1
- package/max/index.js +4 -0
- package/min/es6/exports/AsYouType.js +11 -0
- package/min/es6/exports/Metadata.js +11 -0
- package/min/es6/exports/PhoneNumber.js +11 -0
- package/min/es6/exports/PhoneNumberMatcher.js +11 -0
- package/min/es6/exports/findNumbers.js +6 -0
- package/min/es6/exports/findPhoneNumbersInText.js +6 -0
- package/min/es6/exports/formatIncompletePhoneNumber.js +6 -0
- package/min/es6/exports/getCountries.js +6 -0
- package/min/es6/exports/getCountryCallingCode.js +6 -0
- package/min/es6/exports/getExampleNumber.js +6 -0
- package/min/es6/exports/getExtPrefix.js +6 -0
- package/min/es6/exports/isPossiblePhoneNumber.js +6 -0
- package/min/es6/exports/isSupportedCountry.js +6 -0
- package/min/es6/exports/isValidPhoneNumber.js +6 -0
- package/min/es6/exports/parsePhoneNumber.js +7 -0
- package/min/es6/exports/parsePhoneNumberWithError.js +7 -0
- package/min/es6/exports/searchNumbers.js +6 -0
- package/min/es6/exports/searchPhoneNumbersInText.js +6 -0
- package/min/es6/exports/validatePhoneNumberLength.js +6 -0
- package/min/es6/exports/withMetadataArgument.js +13 -0
- package/min/es6/index.d.cts +2 -0
- package/min/es6/index.d.ts +2 -0
- package/min/es6/index.js +44 -0
- package/min/es6/package.json +12 -0
- package/min/index.cjs +5 -0
- package/min/index.cjs.js +5 -0
- package/min/index.d.cts +3 -1
- package/min/index.d.ts +3 -1
- package/min/index.js +3 -0
- package/mobile/es6/exports/AsYouType.js +11 -0
- package/mobile/es6/exports/Metadata.js +11 -0
- package/mobile/es6/exports/PhoneNumber.js +11 -0
- package/mobile/es6/exports/PhoneNumberMatcher.js +11 -0
- package/mobile/es6/exports/findNumbers.js +6 -0
- package/mobile/es6/exports/findPhoneNumbersInText.js +6 -0
- package/mobile/es6/exports/formatIncompletePhoneNumber.js +6 -0
- package/mobile/es6/exports/getCountries.js +6 -0
- package/mobile/es6/exports/getCountryCallingCode.js +6 -0
- package/mobile/es6/exports/getExampleNumber.js +6 -0
- package/mobile/es6/exports/getExtPrefix.js +6 -0
- package/mobile/es6/exports/isPossiblePhoneNumber.js +6 -0
- package/mobile/es6/exports/isSupportedCountry.js +6 -0
- package/mobile/es6/exports/isValidPhoneNumber.js +6 -0
- package/mobile/es6/exports/parsePhoneNumber.js +7 -0
- package/mobile/es6/exports/parsePhoneNumberWithError.js +7 -0
- package/mobile/es6/exports/searchNumbers.js +6 -0
- package/mobile/es6/exports/searchPhoneNumbersInText.js +6 -0
- package/mobile/es6/exports/validatePhoneNumberLength.js +6 -0
- package/mobile/es6/exports/withMetadataArgument.js +13 -0
- package/mobile/es6/index.d.cts +2 -0
- package/mobile/es6/index.d.ts +2 -0
- package/mobile/es6/index.js +44 -0
- package/mobile/es6/package.json +12 -0
- package/mobile/index.cjs +5 -0
- package/mobile/index.cjs.js +5 -0
- package/mobile/index.d.cts +3 -1
- package/mobile/index.d.ts +3 -1
- package/mobile/index.js +4 -0
- package/package.json +28 -9
- package/types.d.cts +54 -21
- package/types.d.ts +54 -21
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
|
+
import { searchPhoneNumbersInText as _searchPhoneNumbersInText } from '../../../core/es6/index.js'
|
|
3
|
+
|
|
4
|
+
export function searchPhoneNumbersInText() {
|
|
5
|
+
return withMetadataArgument(_searchPhoneNumbersInText, arguments)
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
|
+
import { validatePhoneNumberLength as _validatePhoneNumberLength } from '../../../core/es6/index.js'
|
|
3
|
+
|
|
4
|
+
export function validatePhoneNumberLength() {
|
|
5
|
+
return withMetadataArgument(_validatePhoneNumberLength, arguments)
|
|
6
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Importing from a ".js" file is a workaround for Node.js "ES Modules"
|
|
2
|
+
// importing system which is even uncapable of importing "*.json" files.
|
|
3
|
+
import metadata from '../../../metadata.mobile.json.js'
|
|
4
|
+
|
|
5
|
+
export default function withMetadataArgument(func, _arguments, resultPrototype) {
|
|
6
|
+
var args = Array.prototype.slice.call(_arguments)
|
|
7
|
+
args.push(metadata)
|
|
8
|
+
var result = func.apply(this, args)
|
|
9
|
+
if (resultPrototype && result) {
|
|
10
|
+
Object.setPrototypeOf(result, resultPrototype)
|
|
11
|
+
}
|
|
12
|
+
return result
|
|
13
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
|
|
2
|
+
export { parsePhoneNumberWithError, parsePhoneNumberWithError as parsePhoneNumber } from './exports/parsePhoneNumberWithError.js'
|
|
3
|
+
// `parsePhoneNumberFromString()` named export is now considered legacy:
|
|
4
|
+
// it has been promoted to a default export due to being too verbose.
|
|
5
|
+
export { parsePhoneNumber as parsePhoneNumberFromString, parsePhoneNumber as default } from './exports/parsePhoneNumber.js'
|
|
6
|
+
|
|
7
|
+
export { isValidPhoneNumber } from './exports/isValidPhoneNumber.js'
|
|
8
|
+
export { isPossiblePhoneNumber } from './exports/isPossiblePhoneNumber.js'
|
|
9
|
+
export { validatePhoneNumberLength } from './exports/validatePhoneNumberLength.js'
|
|
10
|
+
|
|
11
|
+
// Deprecated.
|
|
12
|
+
export { findNumbers } from './exports/findNumbers.js'
|
|
13
|
+
export { searchNumbers } from './exports/searchNumbers.js'
|
|
14
|
+
|
|
15
|
+
export { findPhoneNumbersInText } from './exports/findPhoneNumbersInText.js'
|
|
16
|
+
export { searchPhoneNumbersInText } from './exports/searchPhoneNumbersInText.js'
|
|
17
|
+
export { PhoneNumberMatcher } from './exports/PhoneNumberMatcher.js'
|
|
18
|
+
|
|
19
|
+
export { AsYouType } from './exports/AsYouType.js'
|
|
20
|
+
|
|
21
|
+
export { isSupportedCountry } from './exports/isSupportedCountry.js'
|
|
22
|
+
export { getCountries } from './exports/getCountries.js'
|
|
23
|
+
export { getCountryCallingCode } from './exports/getCountryCallingCode.js'
|
|
24
|
+
export { getExtPrefix } from './exports/getExtPrefix.js'
|
|
25
|
+
|
|
26
|
+
export { Metadata } from './exports/Metadata.js'
|
|
27
|
+
export { getExampleNumber } from './exports/getExampleNumber.js'
|
|
28
|
+
|
|
29
|
+
export { formatIncompletePhoneNumber } from './exports/formatIncompletePhoneNumber.js'
|
|
30
|
+
export { PhoneNumber } from './exports/PhoneNumber.js'
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
ParseError,
|
|
34
|
+
parseIncompletePhoneNumber,
|
|
35
|
+
parsePhoneNumberCharacter,
|
|
36
|
+
parseDigits,
|
|
37
|
+
parseRFC3966,
|
|
38
|
+
formatRFC3966,
|
|
39
|
+
// Deprecated:
|
|
40
|
+
// `DIGIT_PLACEHOLDER` is the character that `AsYouType` formatter uses in a phone number template.
|
|
41
|
+
// It's basically an "x" character. I guess, there's no point in exporting it as a constant
|
|
42
|
+
// because the established convention is that it's an "x" character so everyone just assumes "x".
|
|
43
|
+
DIGIT_PLACEHOLDER
|
|
44
|
+
} from '../../core/es6/index.js'
|
package/mobile/index.cjs
CHANGED
|
@@ -102,6 +102,11 @@ exports.formatIncompletePhoneNumber = function formatIncompletePhoneNumber() {
|
|
|
102
102
|
exports.parseIncompletePhoneNumber = core.parseIncompletePhoneNumber
|
|
103
103
|
exports.parsePhoneNumberCharacter = core.parsePhoneNumberCharacter
|
|
104
104
|
exports.parseDigits = core.parseDigits
|
|
105
|
+
|
|
106
|
+
// Deprecated:
|
|
107
|
+
// `DIGIT_PLACEHOLDER` is the character that `AsYouType` formatter uses in a phone number template.
|
|
108
|
+
// It's basically an "x" character. I guess, there's no point in exporting it as a constant
|
|
109
|
+
// because the established convention is that it's an "x" character so everyone just assumes "x".
|
|
105
110
|
exports.DIGIT_PLACEHOLDER = core.DIGIT_PLACEHOLDER
|
|
106
111
|
|
|
107
112
|
exports.parseRFC3966 = core.parseRFC3966
|
package/mobile/index.cjs.js
CHANGED
|
@@ -107,6 +107,11 @@ exports.formatIncompletePhoneNumber = function formatIncompletePhoneNumber() {
|
|
|
107
107
|
exports.parseIncompletePhoneNumber = core.parseIncompletePhoneNumber
|
|
108
108
|
exports.parsePhoneNumberCharacter = core.parsePhoneNumberCharacter
|
|
109
109
|
exports.parseDigits = core.parseDigits
|
|
110
|
+
|
|
111
|
+
// Deprecated:
|
|
112
|
+
// `DIGIT_PLACEHOLDER` is the character that `AsYouType` formatter uses in a phone number template.
|
|
113
|
+
// It's basically an "x" character. I guess, there's no point in exporting it as a constant
|
|
114
|
+
// because the established convention is that it's an "x" character so everyone just assumes "x".
|
|
110
115
|
exports.DIGIT_PLACEHOLDER = core.DIGIT_PLACEHOLDER
|
|
111
116
|
|
|
112
117
|
exports.parseRFC3966 = core.parseRFC3966
|
package/mobile/index.d.cts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Extension,
|
|
10
10
|
ParseError,
|
|
11
11
|
NumberFoundLegacy,
|
|
12
|
+
PhoneNumberType,
|
|
12
13
|
NumberType,
|
|
13
14
|
NumberFormat,
|
|
14
15
|
NumberingPlan,
|
|
@@ -30,6 +31,7 @@ export {
|
|
|
30
31
|
Extension,
|
|
31
32
|
ParseError,
|
|
32
33
|
NumberFoundLegacy,
|
|
34
|
+
PhoneNumberType,
|
|
33
35
|
NumberType,
|
|
34
36
|
NumberFormat,
|
|
35
37
|
NumberingPlan,
|
|
@@ -48,7 +50,7 @@ export class PhoneNumber {
|
|
|
48
50
|
getPossibleCountries(): CountryCode[];
|
|
49
51
|
isPossible(): boolean;
|
|
50
52
|
isValid(): boolean;
|
|
51
|
-
getType():
|
|
53
|
+
getType(): PhoneNumberType | undefined;
|
|
52
54
|
format(format: NumberFormat, options?: FormatNumberOptions): string;
|
|
53
55
|
formatNational(options?: FormatNumberOptionsForNationalOrInternational): string;
|
|
54
56
|
formatInternational(options?: FormatNumberOptionsForNationalOrInternational): string;
|
package/mobile/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Extension,
|
|
10
10
|
ParseError,
|
|
11
11
|
NumberFoundLegacy,
|
|
12
|
+
PhoneNumberType,
|
|
12
13
|
NumberType,
|
|
13
14
|
NumberFormat,
|
|
14
15
|
NumberingPlan,
|
|
@@ -30,6 +31,7 @@ export {
|
|
|
30
31
|
Extension,
|
|
31
32
|
ParseError,
|
|
32
33
|
NumberFoundLegacy,
|
|
34
|
+
PhoneNumberType,
|
|
33
35
|
NumberType,
|
|
34
36
|
NumberFormat,
|
|
35
37
|
NumberingPlan,
|
|
@@ -48,7 +50,7 @@ export class PhoneNumber {
|
|
|
48
50
|
getPossibleCountries(): CountryCode[];
|
|
49
51
|
isPossible(): boolean;
|
|
50
52
|
isValid(): boolean;
|
|
51
|
-
getType():
|
|
53
|
+
getType(): PhoneNumberType | undefined;
|
|
52
54
|
format(format: NumberFormat, options?: FormatNumberOptions): string;
|
|
53
55
|
formatNational(options?: FormatNumberOptionsForNationalOrInternational): string;
|
|
54
56
|
formatInternational(options?: FormatNumberOptionsForNationalOrInternational): string;
|
package/mobile/index.js
CHANGED
|
@@ -36,5 +36,9 @@ export {
|
|
|
36
36
|
parseDigits,
|
|
37
37
|
parseRFC3966,
|
|
38
38
|
formatRFC3966,
|
|
39
|
+
// Deprecated:
|
|
40
|
+
// `DIGIT_PLACEHOLDER` is the character that `AsYouType` formatter uses in a phone number template.
|
|
41
|
+
// It's basically an "x" character. I guess, there's no point in exporting it as a constant
|
|
42
|
+
// because the established convention is that it's an "x" character so everyone just assumes "x".
|
|
39
43
|
DIGIT_PLACEHOLDER
|
|
40
44
|
} from '../core/index.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libphonenumber-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.1",
|
|
4
4
|
"description": "A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript",
|
|
5
5
|
"main": "index.cjs",
|
|
6
6
|
"module": "index.js",
|
|
@@ -26,6 +26,22 @@
|
|
|
26
26
|
"import": "./core/index.js",
|
|
27
27
|
"require": "./core/index.cjs"
|
|
28
28
|
},
|
|
29
|
+
"./min/es6": {
|
|
30
|
+
"types": "./min/es6/index.d.ts",
|
|
31
|
+
"import": "./min/es6/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./max/es6": {
|
|
34
|
+
"types": "./max/es6/index.d.ts",
|
|
35
|
+
"import": "./max/es6/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./mobile/es6": {
|
|
38
|
+
"types": "./mobile/es6/index.d.ts",
|
|
39
|
+
"import": "./mobile/es6/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./core/es6": {
|
|
42
|
+
"types": "./core/es6/index.d.ts",
|
|
43
|
+
"import": "./core/es6/index.js"
|
|
44
|
+
},
|
|
29
45
|
"./min/metadata": {
|
|
30
46
|
"import": "./metadata.min.json.js",
|
|
31
47
|
"require": "./metadata.min.json"
|
|
@@ -103,7 +119,7 @@
|
|
|
103
119
|
"istanbul": "^1.1.0-alpha.1",
|
|
104
120
|
"jest": "^30.0.5",
|
|
105
121
|
"jest-codemods": "^0.34.2",
|
|
106
|
-
"libphonenumber-metadata-generator": "^2.0.
|
|
122
|
+
"libphonenumber-metadata-generator": "^2.0.6",
|
|
107
123
|
"minimist": "^1.2.8",
|
|
108
124
|
"mocha": "^10.0.0",
|
|
109
125
|
"npm-run-all": "^4.1.5",
|
|
@@ -117,11 +133,13 @@
|
|
|
117
133
|
"scripts": {
|
|
118
134
|
"metadata:update:job": "node build-scripts/check-for-uncommitted-files && git reset --hard && git pull && npm install && npm run metadata:update-and-release",
|
|
119
135
|
"metadata:update-and-release": "node build-scripts/pull-google-metadata ./PhoneNumberMetadata.xml ./metadata-info.json && node build-scripts/check-for-metadata-changes-and-release ./PhoneNumberMetadata.xml ./metadata-info.json",
|
|
120
|
-
"metadata:generate": "npm-run-all metadata:generate:min metadata:generate:full metadata:generate:max metadata:generate:mobile metadata:generate:min:js metadata:generate:full:js metadata:generate:max:js metadata:generate:mobile:js metadata:generate:mobile:examples:js",
|
|
121
|
-
"metadata:generate:
|
|
122
|
-
"metadata:generate:
|
|
123
|
-
"metadata:generate:
|
|
124
|
-
"metadata:generate:
|
|
136
|
+
"metadata:generate": "npm-run-all metadata:generate:non-minified metadata:generate:min metadata:generate:full metadata:generate:max metadata:generate:mobile metadata:generate:mobile:examples metadata:generate:min:js metadata:generate:full:js metadata:generate:max:js metadata:generate:mobile:js metadata:generate:mobile:examples:js",
|
|
137
|
+
"metadata:generate:non-minified": "node build-scripts/generate-metadata-from-google-metadata ./PhoneNumberMetadata.xml ./metadata.json --with-phone-number-types --with-phone-number-type-examples --non-minified",
|
|
138
|
+
"metadata:generate:min": "node build-scripts/generate-metadata-from-google-metadata ./PhoneNumberMetadata.xml ./metadata.min.json",
|
|
139
|
+
"metadata:generate:full": "node build-scripts/generate-metadata-from-google-metadata ./PhoneNumberMetadata.xml ./metadata.full.json --with-phone-number-types",
|
|
140
|
+
"metadata:generate:max": "node build-scripts/generate-metadata-from-google-metadata ./PhoneNumberMetadata.xml ./metadata.max.json --with-phone-number-types",
|
|
141
|
+
"metadata:generate:mobile": "node build-scripts/generate-metadata-from-google-metadata ./PhoneNumberMetadata.xml ./metadata.mobile.json --with-phone-number-types --phone-number-types mobile",
|
|
142
|
+
"metadata:generate:mobile:examples": "node build-scripts/generate-metadata-from-google-metadata ./PhoneNumberMetadata.xml ./examples.mobile.json --with-phone-number-type-examples --phone-number-type-examples mobile",
|
|
125
143
|
"metadata:generate:min:js": "node build-scripts/create-js-file-for-json-file ./metadata.min.json",
|
|
126
144
|
"metadata:generate:full:js": "node build-scripts/create-js-file-for-json-file ./metadata.full.json",
|
|
127
145
|
"metadata:generate:max:js": "node build-scripts/create-js-file-for-json-file ./metadata.max.json",
|
|
@@ -143,7 +161,7 @@
|
|
|
143
161
|
"test:esm--nyc--does-not-seem-to-work": "cross-env nyc mocha --bail --require @babel/register --require ./test/globals.js \"source/**/*.test.js\" \"test/**/*.test.js\"",
|
|
144
162
|
"test-coverage--nyc--does-not-seem-to-work": "nyc report --reporter=text-lcov",
|
|
145
163
|
"test-travis": "node --experimental-json-modules node_modules/istanbul/lib/cli.js cover -x \"build/**\" -x \"es6/**\" -x \"*.test.js\" -x \"source/findNumbers/Leniency.js\" -x \"source/findNumbers/matchPhoneNumberStringAgainstPhoneNumber.js\" -x \"source/findNumbers/RegExpCache.js\" -x \"source/findNumbers/LRUCache.js\" -x \"source/PhoneNumberMatcher.js\" -x \"source/tools/semver-compare.js\" node_modules/mocha/bin/_mocha --report lcovonly -- --colors --reporter spec --require ./test/globals.js \"source/**/*.test.js\" \"test/**/*.test.js\" --recursive",
|
|
146
|
-
"clean": "rimraf --glob ./build/**/* ./es6/**/*",
|
|
164
|
+
"clean": "rimraf --glob ./build/**/* ./es6/**/* ./es6-modern/**/*",
|
|
147
165
|
"build:commonjs": "npm-run-all build:commonjs:with-tests build:commonjs:package.json build:commonjs:create-typescript-definitions build:commonjs:patch-typescript-definitions",
|
|
148
166
|
"build:commonjs:before-es-modules": "cross-env BABEL_ENV=commonjs babel ./source --out-dir ./build --source-maps --ignore test.js",
|
|
149
167
|
"build:commonjs:with-tests": "cross-env BABEL_ENV=commonjs babel ./source --out-dir ./build --source-maps",
|
|
@@ -158,8 +176,9 @@
|
|
|
158
176
|
"build:copy-examples-files-to-subpackage-folders:mobile": "cpy --flat examples.mobile.json examples.mobile.json.js examples.mobile.json.d.ts mobile/examples && replace-in-file \" from './\" \" from '../../\" mobile/examples/examples.*.json.d.*",
|
|
159
177
|
"build:copy-examples-files-to-subpackage-folders": "npm-run-all build:copy-examples-files-to-subpackage-folders:mobile",
|
|
160
178
|
"build:modules": "cross-env BABEL_ENV=es6 babel ./source --out-dir ./es6 --source-maps --ignore test.js",
|
|
179
|
+
"build:modules:modern": "cross-env BABEL_ENV=es6-modern babel ./source --out-dir ./es6-modern --source-maps --ignore test.js",
|
|
161
180
|
"build:bundle": "rollup --config rollup.config.mjs",
|
|
162
|
-
"build": "npm-run-all clean build:modules:copy-typescript-definitions build:modules build:commonjs build:bundle build:copy-metadata-files-to-subpackage-folders build:copy-examples-files-to-subpackage-folders",
|
|
181
|
+
"build": "npm-run-all clean build:modules:copy-typescript-definitions build:modules build:modules:modern build:commonjs build:bundle build:copy-metadata-files-to-subpackage-folders build:copy-examples-files-to-subpackage-folders",
|
|
163
182
|
"prepublishOnly": "npm run metadata:generate && npm run typescript:generate-country-codes-list && crlf --set=LF metadata.*.json && npm-run-all build test test:exports"
|
|
164
183
|
},
|
|
165
184
|
"repository": {
|
package/types.d.cts
CHANGED
|
@@ -14,34 +14,57 @@ export type CountryCode = 'AC' | 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM'
|
|
|
14
14
|
// // https://github.com/catamphetamine/libphonenumber-js/issues/405
|
|
15
15
|
// export type CountryCode = typeof CountryCodes[number];
|
|
16
16
|
|
|
17
|
-
export type
|
|
18
|
-
|
|
17
|
+
export type CountryCallingCodeToCountryCodes = {
|
|
18
|
+
// For each "calling code", it lists the countries that have it.
|
|
19
|
+
[countryCallingCode: CountryCallingCode]: CountryCode[];
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
// A non-minified telephone numbering plan looks like:
|
|
23
|
+
//
|
|
24
|
+
// {
|
|
25
|
+
// phone_code: string,
|
|
26
|
+
// idd_prefix: string,
|
|
27
|
+
// national_number_pattern: string,
|
|
28
|
+
// types: object,
|
|
29
|
+
// examples: object,
|
|
30
|
+
// formats: object[]?,
|
|
31
|
+
// possible_lengths: number[],
|
|
32
|
+
// ...
|
|
33
|
+
// }
|
|
34
|
+
//
|
|
35
|
+
// While minified telephone numbering plan is the same data but in the form of an array
|
|
36
|
+
// where each index corresponds to a pre-defined property name in the original object.
|
|
37
|
+
//
|
|
38
|
+
export type MinifiedTelephoneNumberingPlan = any[];
|
|
39
|
+
|
|
40
|
+
// Telephone numbering plan for each country.
|
|
41
|
+
export type CountryCodeToMinifiedTelephoneNumberingPlan = {
|
|
36
42
|
// `in` operator docs:
|
|
37
43
|
// https://www.typescriptlang.org/docs/handbook/advanced-types.html#mapped-types
|
|
38
44
|
// `country in CountryCode` means "for each and every CountryCode".
|
|
39
|
-
[country in CountryCode]?:
|
|
45
|
+
[country in CountryCode]?: MinifiedTelephoneNumberingPlan;
|
|
40
46
|
};
|
|
41
47
|
|
|
42
48
|
export type MetadataJson = {
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
// Metadata format version.
|
|
50
|
+
// Previously, it used to be a "semver" string but now it's an integer.
|
|
51
|
+
// Specifically:
|
|
52
|
+
// There was no `version` property in V1 of metadata.
|
|
53
|
+
// Then, `version` was a "semver" string in V2, V3 and V4 of metadata.
|
|
54
|
+
// Then, metadata stayed at version V4 but the `version` property was changed to a simple integer.
|
|
55
|
+
// From then on, `version` has stayed at numeric value `4`.
|
|
56
|
+
version: number;
|
|
57
|
+
// For each "calling code", it lists the countries that have it.
|
|
58
|
+
// Some "calling codes" correspond to only one country.
|
|
59
|
+
// Others are shared between multiple countries.
|
|
60
|
+
country_calling_codes: CountryCallingCodeToCountryCodes;
|
|
61
|
+
// Telephone numbering plan for each country.
|
|
62
|
+
countries: CountryCodeToMinifiedTelephoneNumberingPlan;
|
|
63
|
+
// Telephone numbering plans for "non-geographic" calling codes.
|
|
64
|
+
// http://npmjs.com/package/libphonenumber-js#non-geographic
|
|
65
|
+
// "Non-geographic" calling codes are "calling codes" that don't belong to
|
|
66
|
+
// any given country or territory and are inherently international.
|
|
67
|
+
nonGeographic: Record<CountryCallingCode, MinifiedTelephoneNumberingPlan>;
|
|
45
68
|
};
|
|
46
69
|
|
|
47
70
|
export type Examples = {
|
|
@@ -52,7 +75,17 @@ export type Examples = {
|
|
|
52
75
|
};
|
|
53
76
|
|
|
54
77
|
export type NumberFormat = 'NATIONAL' | 'INTERNATIONAL' | 'E.164' | 'RFC3966' | 'IDD';
|
|
55
|
-
export type
|
|
78
|
+
export type PhoneNumberType = 'PREMIUM_RATE' | 'TOLL_FREE' | 'SHARED_COST' | 'VOIP' | 'PERSONAL_NUMBER' | 'PAGER' | 'UAN' | 'VOICEMAIL' | 'FIXED_LINE_OR_MOBILE' | 'FIXED_LINE' | 'MOBILE';
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated Originally, for some weird reason, someone decided to declare
|
|
82
|
+
* `NumberType` type as `undefined | 'PREMIUM_RATE' | 'TOLL_FREE' | ...`
|
|
83
|
+
* which doesn't make any sense — why even include `undefined` in there?
|
|
84
|
+
* At that time, I wasn't familiar with TypeScript so this weird type definition slipped through.
|
|
85
|
+
* Now though I can see how "unconventional" it looks, so I created a new type
|
|
86
|
+
* called `PhoneNumberType` which is same as `NumberType` except it can't be `undefined`.
|
|
87
|
+
*/
|
|
88
|
+
export type NumberType = PhoneNumberType | undefined;
|
|
56
89
|
|
|
57
90
|
// "Tagged" types are used to introduce some degree of type safety when passing in arguments to the functions.
|
|
58
91
|
// https://medium.com/@ethanresnick/advanced-typescript-tagged-types-for-fewer-bugs-and-better-security-24db681d5721
|
package/types.d.ts
CHANGED
|
@@ -14,34 +14,57 @@ export type CountryCode = 'AC' | 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM'
|
|
|
14
14
|
// // https://github.com/catamphetamine/libphonenumber-js/issues/405
|
|
15
15
|
// export type CountryCode = typeof CountryCodes[number];
|
|
16
16
|
|
|
17
|
-
export type
|
|
18
|
-
|
|
17
|
+
export type CountryCallingCodeToCountryCodes = {
|
|
18
|
+
// For each "calling code", it lists the countries that have it.
|
|
19
|
+
[countryCallingCode: CountryCallingCode]: CountryCode[];
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
// A non-minified telephone numbering plan looks like:
|
|
23
|
+
//
|
|
24
|
+
// {
|
|
25
|
+
// phone_code: string,
|
|
26
|
+
// idd_prefix: string,
|
|
27
|
+
// national_number_pattern: string,
|
|
28
|
+
// types: object,
|
|
29
|
+
// examples: object,
|
|
30
|
+
// formats: object[]?,
|
|
31
|
+
// possible_lengths: number[],
|
|
32
|
+
// ...
|
|
33
|
+
// }
|
|
34
|
+
//
|
|
35
|
+
// While minified telephone numbering plan is the same data but in the form of an array
|
|
36
|
+
// where each index corresponds to a pre-defined property name in the original object.
|
|
37
|
+
//
|
|
38
|
+
export type MinifiedTelephoneNumberingPlan = any[];
|
|
39
|
+
|
|
40
|
+
// Telephone numbering plan for each country.
|
|
41
|
+
export type CountryCodeToMinifiedTelephoneNumberingPlan = {
|
|
36
42
|
// `in` operator docs:
|
|
37
43
|
// https://www.typescriptlang.org/docs/handbook/advanced-types.html#mapped-types
|
|
38
44
|
// `country in CountryCode` means "for each and every CountryCode".
|
|
39
|
-
[country in CountryCode]?:
|
|
45
|
+
[country in CountryCode]?: MinifiedTelephoneNumberingPlan;
|
|
40
46
|
};
|
|
41
47
|
|
|
42
48
|
export type MetadataJson = {
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
// Metadata format version.
|
|
50
|
+
// Previously, it used to be a "semver" string but now it's an integer.
|
|
51
|
+
// Specifically:
|
|
52
|
+
// There was no `version` property in V1 of metadata.
|
|
53
|
+
// Then, `version` was a "semver" string in V2, V3 and V4 of metadata.
|
|
54
|
+
// Then, metadata stayed at version V4 but the `version` property was changed to a simple integer.
|
|
55
|
+
// From then on, `version` has stayed at numeric value `4`.
|
|
56
|
+
version: number;
|
|
57
|
+
// For each "calling code", it lists the countries that have it.
|
|
58
|
+
// Some "calling codes" correspond to only one country.
|
|
59
|
+
// Others are shared between multiple countries.
|
|
60
|
+
country_calling_codes: CountryCallingCodeToCountryCodes;
|
|
61
|
+
// Telephone numbering plan for each country.
|
|
62
|
+
countries: CountryCodeToMinifiedTelephoneNumberingPlan;
|
|
63
|
+
// Telephone numbering plans for "non-geographic" calling codes.
|
|
64
|
+
// http://npmjs.com/package/libphonenumber-js#non-geographic
|
|
65
|
+
// "Non-geographic" calling codes are "calling codes" that don't belong to
|
|
66
|
+
// any given country or territory and are inherently international.
|
|
67
|
+
nonGeographic: Record<CountryCallingCode, MinifiedTelephoneNumberingPlan>;
|
|
45
68
|
};
|
|
46
69
|
|
|
47
70
|
export type Examples = {
|
|
@@ -52,7 +75,17 @@ export type Examples = {
|
|
|
52
75
|
};
|
|
53
76
|
|
|
54
77
|
export type NumberFormat = 'NATIONAL' | 'INTERNATIONAL' | 'E.164' | 'RFC3966' | 'IDD';
|
|
55
|
-
export type
|
|
78
|
+
export type PhoneNumberType = 'PREMIUM_RATE' | 'TOLL_FREE' | 'SHARED_COST' | 'VOIP' | 'PERSONAL_NUMBER' | 'PAGER' | 'UAN' | 'VOICEMAIL' | 'FIXED_LINE_OR_MOBILE' | 'FIXED_LINE' | 'MOBILE';
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated Originally, for some weird reason, someone decided to declare
|
|
82
|
+
* `NumberType` type as `undefined | 'PREMIUM_RATE' | 'TOLL_FREE' | ...`
|
|
83
|
+
* which doesn't make any sense — why even include `undefined` in there?
|
|
84
|
+
* At that time, I wasn't familiar with TypeScript so this weird type definition slipped through.
|
|
85
|
+
* Now though I can see how "unconventional" it looks, so I created a new type
|
|
86
|
+
* called `PhoneNumberType` which is same as `NumberType` except it can't be `undefined`.
|
|
87
|
+
*/
|
|
88
|
+
export type NumberType = PhoneNumberType | undefined;
|
|
56
89
|
|
|
57
90
|
// "Tagged" types are used to introduce some degree of type safety when passing in arguments to the functions.
|
|
58
91
|
// https://medium.com/@ethanresnick/advanced-typescript-tagged-types-for-fewer-bugs-and-better-security-24db681d5721
|