libphonenumber-js 1.10.5 → 1.10.8
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/build/AsYouType.test.js +26 -8
- package/build/AsYouType.test.js.map +1 -1
- package/build/AsYouTypeFormatter.PatternMatcher.js +36 -224
- package/build/AsYouTypeFormatter.PatternMatcher.js.map +1 -1
- package/build/AsYouTypeFormatter.PatternMatcher.test.js +9 -0
- package/build/AsYouTypeFormatter.PatternMatcher.test.js.map +1 -1
- package/build/AsYouTypeFormatter.PatternParser.js +241 -0
- package/build/AsYouTypeFormatter.PatternParser.js.map +1 -0
- package/build/AsYouTypeFormatter.PatternParser.test.js +49 -0
- package/build/AsYouTypeFormatter.PatternParser.test.js.map +1 -0
- package/build/AsYouTypeFormatter.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.test.js +26 -8
- package/es6/AsYouType.test.js.map +1 -1
- package/es6/AsYouTypeFormatter.PatternMatcher.js +33 -223
- package/es6/AsYouTypeFormatter.PatternMatcher.js.map +1 -1
- package/es6/AsYouTypeFormatter.PatternMatcher.test.js +9 -0
- package/es6/AsYouTypeFormatter.PatternMatcher.test.js.map +1 -1
- package/es6/AsYouTypeFormatter.PatternParser.js +234 -0
- package/es6/AsYouTypeFormatter.PatternParser.js.map +1 -0
- package/es6/AsYouTypeFormatter.PatternParser.test.js +44 -0
- package/es6/AsYouTypeFormatter.PatternParser.test.js.map +1 -0
- package/es6/AsYouTypeFormatter.js.map +1 -1
- package/index.cjs +9 -9
- package/index.cjs.js +9 -9
- package/index.es6.exports/PhoneNumberSearch.js +3 -1
- package/index.es6.exports/findPhoneNumbers.js +2 -2
- package/index.es6.exports/format.js +2 -2
- package/index.es6.exports/getNumberType.js +2 -2
- package/index.es6.exports/isPossibleNumber.js +2 -2
- package/index.es6.exports/isValidNumber.js +2 -2
- package/index.es6.exports/isValidNumberForRegion.js +2 -2
- package/index.es6.exports/parse.js +2 -2
- package/index.es6.exports/searchPhoneNumbers.js +2 -2
- package/max/exports/AsYouType.js +4 -1
- package/max/exports/Metadata.js +4 -1
- package/max/exports/PhoneNumberMatcher.js +4 -1
- package/max/exports/findNumbers.js +2 -2
- package/max/exports/findPhoneNumbersInText.js +2 -2
- package/max/exports/formatIncompletePhoneNumber.js +2 -2
- package/max/exports/getCountries.js +2 -2
- package/max/exports/getCountryCallingCode.js +2 -2
- package/max/exports/getExampleNumber.js +2 -2
- package/max/exports/getExtPrefix.js +2 -2
- package/max/exports/isPossiblePhoneNumber.js +2 -2
- package/max/exports/isSupportedCountry.js +2 -2
- package/max/exports/isValidPhoneNumber.js +2 -2
- package/max/exports/parsePhoneNumberFromString.js +2 -2
- package/max/exports/parsePhoneNumberWithError.js +2 -2
- package/max/exports/searchNumbers.js +2 -2
- package/max/exports/searchPhoneNumbersInText.js +2 -2
- package/max/exports/validatePhoneNumberLength.js +2 -2
- package/max/exports/withMetadataArgument.js +9 -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/min/exports/AsYouType.js +4 -1
- package/min/exports/Metadata.js +4 -1
- package/min/exports/PhoneNumberMatcher.js +4 -1
- package/min/exports/findNumbers.js +2 -2
- package/min/exports/findPhoneNumbersInText.js +2 -2
- package/min/exports/formatIncompletePhoneNumber.js +2 -2
- package/min/exports/getCountries.js +2 -2
- package/min/exports/getCountryCallingCode.js +2 -2
- package/min/exports/getExampleNumber.js +2 -2
- package/min/exports/getExtPrefix.js +2 -2
- package/min/exports/isPossiblePhoneNumber.js +2 -2
- package/min/exports/isSupportedCountry.js +2 -2
- package/min/exports/isValidPhoneNumber.js +2 -2
- package/min/exports/parsePhoneNumberFromString.js +2 -2
- package/min/exports/parsePhoneNumberWithError.js +2 -2
- package/min/exports/searchNumbers.js +2 -2
- package/min/exports/searchPhoneNumbersInText.js +2 -2
- package/min/exports/validatePhoneNumberLength.js +2 -2
- package/min/exports/withMetadataArgument.js +9 -0
- package/mobile/exports/AsYouType.js +4 -1
- package/mobile/exports/Metadata.js +4 -1
- package/mobile/exports/PhoneNumberMatcher.js +4 -1
- package/mobile/exports/findNumbers.js +2 -2
- package/mobile/exports/findPhoneNumbersInText.js +2 -2
- package/mobile/exports/formatIncompletePhoneNumber.js +2 -2
- package/mobile/exports/getCountries.js +2 -2
- package/mobile/exports/getCountryCallingCode.js +2 -2
- package/mobile/exports/getExampleNumber.js +2 -2
- package/mobile/exports/getExtPrefix.js +2 -2
- package/mobile/exports/isPossiblePhoneNumber.js +2 -2
- package/mobile/exports/isSupportedCountry.js +2 -2
- package/mobile/exports/isValidPhoneNumber.js +2 -2
- package/mobile/exports/parsePhoneNumberFromString.js +2 -2
- package/mobile/exports/parsePhoneNumberWithError.js +2 -2
- package/mobile/exports/searchNumbers.js +2 -2
- package/mobile/exports/searchPhoneNumbersInText.js +2 -2
- package/mobile/exports/validatePhoneNumberLength.js +2 -2
- package/mobile/exports/withMetadataArgument.js +9 -0
- package/package.json +1 -1
- package/source/AsYouType.test.js +25 -6
- package/source/AsYouTypeFormatter.PatternMatcher.d.ts +66 -0
- package/source/AsYouTypeFormatter.PatternMatcher.js +30 -206
- package/source/AsYouTypeFormatter.PatternMatcher.test.js +8 -0
- package/source/AsYouTypeFormatter.PatternParser.d.ts +58 -0
- package/source/AsYouTypeFormatter.PatternParser.js +214 -0
- package/source/AsYouTypeFormatter.PatternParser.test.js +67 -0
- package/source/AsYouTypeFormatter.js +2 -0
- package/max/metadata.js +0 -11
- package/min/metadata.js +0 -11
- package/mobile/metadata.js +0 -11
package/min/exports/AsYouType.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
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.min.json.js'
|
|
4
|
+
|
|
2
5
|
import { AsYouType as _AsYouType } from '../../core/index.js'
|
|
3
6
|
|
|
4
7
|
export function AsYouType(country) {
|
package/min/exports/Metadata.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
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.min.json.js'
|
|
4
|
+
|
|
2
5
|
import { Metadata as _Metadata } from '../../core/index.js'
|
|
3
6
|
|
|
4
7
|
export function Metadata() {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
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.min.json.js'
|
|
4
|
+
|
|
2
5
|
import { PhoneNumberMatcher as _PhoneNumberMatcher } from '../../core/index.js'
|
|
3
6
|
|
|
4
7
|
export function PhoneNumberMatcher(text, options) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { findNumbers as _findNumbers } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function findNumbers() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_findNumbers, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { findPhoneNumbersInText as _findPhoneNumbersInText } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function findPhoneNumbersInText() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_findPhoneNumbersInText, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { formatIncompletePhoneNumber as _formatIncompletePhoneNumber } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function formatIncompletePhoneNumber() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_formatIncompletePhoneNumber, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { getCountries as _getCountries } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function getCountries() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_getCountries, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { getCountryCallingCode as _getCountryCallingCode } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function getCountryCallingCode() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_getCountryCallingCode, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { getExampleNumber as _getExampleNumber } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function getExampleNumber() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_getExampleNumber, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { getExtPrefix as _getExtPrefix } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function getExtPrefix() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_getExtPrefix, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { isPossiblePhoneNumber as _isPossiblePhoneNumber } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function isPossiblePhoneNumber() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_isPossiblePhoneNumber, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { isSupportedCountry as _isSupportedCountry } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function isSupportedCountry() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_isSupportedCountry, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { isValidPhoneNumber as _isValidPhoneNumber } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function isValidPhoneNumber() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_isValidPhoneNumber, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { parsePhoneNumberFromString as _parsePhoneNumberFromString } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function parsePhoneNumberFromString() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_parsePhoneNumberFromString, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { parsePhoneNumberWithError as _parsePhoneNumberWithError } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function parsePhoneNumberWithError() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_parsePhoneNumberWithError, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { searchNumbers as _searchNumbers } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function searchNumbers() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_searchNumbers, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { searchPhoneNumbersInText as _searchPhoneNumbersInText } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function searchPhoneNumbersInText() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_searchPhoneNumbersInText, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { validatePhoneNumberLength as _validatePhoneNumberLength } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function validatePhoneNumberLength() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_validatePhoneNumberLength, arguments)
|
|
6
6
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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.min.json.js'
|
|
4
|
+
|
|
5
|
+
export default function withMetadataArgument(func, _arguments) {
|
|
6
|
+
var args = Array.prototype.slice.call(_arguments)
|
|
7
|
+
args.push(metadata)
|
|
8
|
+
return func.apply(this, args)
|
|
9
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
2
5
|
import { AsYouType as _AsYouType } from '../../core/index.js'
|
|
3
6
|
|
|
4
7
|
export function AsYouType(country) {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
2
5
|
import { Metadata as _Metadata } from '../../core/index.js'
|
|
3
6
|
|
|
4
7
|
export function Metadata() {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
2
5
|
import { PhoneNumberMatcher as _PhoneNumberMatcher } from '../../core/index.js'
|
|
3
6
|
|
|
4
7
|
export function PhoneNumberMatcher(text, options) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { findNumbers as _findNumbers } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function findNumbers() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_findNumbers, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { findPhoneNumbersInText as _findPhoneNumbersInText } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function findPhoneNumbersInText() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_findPhoneNumbersInText, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { formatIncompletePhoneNumber as _formatIncompletePhoneNumber } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function formatIncompletePhoneNumber() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_formatIncompletePhoneNumber, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { getCountries as _getCountries } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function getCountries() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_getCountries, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { getCountryCallingCode as _getCountryCallingCode } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function getCountryCallingCode() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_getCountryCallingCode, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { getExampleNumber as _getExampleNumber } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function getExampleNumber() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_getExampleNumber, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { getExtPrefix as _getExtPrefix } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function getExtPrefix() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_getExtPrefix, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { isPossiblePhoneNumber as _isPossiblePhoneNumber } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function isPossiblePhoneNumber() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_isPossiblePhoneNumber, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { isSupportedCountry as _isSupportedCountry } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function isSupportedCountry() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_isSupportedCountry, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { isValidPhoneNumber as _isValidPhoneNumber } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function isValidPhoneNumber() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_isValidPhoneNumber, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { parsePhoneNumberFromString as _parsePhoneNumberFromString } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function parsePhoneNumberFromString() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_parsePhoneNumberFromString, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { parsePhoneNumberWithError as _parsePhoneNumberWithError } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function parsePhoneNumberWithError() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_parsePhoneNumberWithError, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { searchNumbers as _searchNumbers } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function searchNumbers() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_searchNumbers, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { searchPhoneNumbersInText as _searchPhoneNumbersInText } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function searchPhoneNumbersInText() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_searchPhoneNumbersInText, arguments)
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import withMetadataArgument from './withMetadataArgument.js'
|
|
2
2
|
import { validatePhoneNumberLength as _validatePhoneNumberLength } from '../../core/index.js'
|
|
3
3
|
|
|
4
4
|
export function validatePhoneNumberLength() {
|
|
5
|
-
return
|
|
5
|
+
return withMetadataArgument(_validatePhoneNumberLength, arguments)
|
|
6
6
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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) {
|
|
6
|
+
var args = Array.prototype.slice.call(_arguments)
|
|
7
|
+
args.push(metadata)
|
|
8
|
+
return func.apply(this, args)
|
|
9
|
+
}
|
package/package.json
CHANGED
package/source/AsYouType.test.js
CHANGED
|
@@ -20,8 +20,10 @@ describe('AsYouType', () => {
|
|
|
20
20
|
it('should populate national number template (digit by digit)', () => {
|
|
21
21
|
const formatter = new AsYouType('US')
|
|
22
22
|
formatter.input('1')
|
|
23
|
-
formatter.formatter.template.should.equal('x (xxx) xxx-xxxx')
|
|
24
|
-
formatter.formatter.
|
|
23
|
+
// formatter.formatter.template.should.equal('x (xxx) xxx-xxxx')
|
|
24
|
+
formatter.formatter.template.should.equal('x xxx-xxxx')
|
|
25
|
+
// formatter.formatter.populatedNationalNumberTemplate.should.equal('1 (xxx) xxx-xxxx')
|
|
26
|
+
formatter.formatter.populatedNationalNumberTemplate.should.equal('1 xxx-xxxx')
|
|
25
27
|
formatter.input('213')
|
|
26
28
|
formatter.formatter.populatedNationalNumberTemplate.should.equal('1 (213) xxx-xxxx')
|
|
27
29
|
formatter.input('3734253')
|
|
@@ -42,8 +44,10 @@ describe('AsYouType', () => {
|
|
|
42
44
|
formatter.input('1').should.equal('+1')
|
|
43
45
|
formatter.getTemplate().should.equal('xx')
|
|
44
46
|
// Hasn't started formatting the phone number using the template yet.
|
|
45
|
-
formatter.formatter.template.should.equal('xx xxx xxx xxxx')
|
|
46
|
-
formatter.formatter.
|
|
47
|
+
// formatter.formatter.template.should.equal('xx xxx xxx xxxx')
|
|
48
|
+
formatter.formatter.template.should.equal('xx xxx xxxx')
|
|
49
|
+
// formatter.formatter.populatedNationalNumberTemplate.should.equal('xxx xxx xxxx')
|
|
50
|
+
formatter.formatter.populatedNationalNumberTemplate.should.equal('xxx xxxx')
|
|
47
51
|
// Has some national number digits, starts formatting the phone number using the template.
|
|
48
52
|
formatter.input('213')
|
|
49
53
|
formatter.formatter.populatedNationalNumberTemplate.should.equal('213 xxx xxxx')
|
|
@@ -62,9 +66,11 @@ describe('AsYouType', () => {
|
|
|
62
66
|
expect(formatter.formatter.template).to.be.undefined
|
|
63
67
|
expect(formatter.formatter.populatedNationalNumberTemplate).to.be.undefined
|
|
64
68
|
formatter.input('1').should.equal('+1')
|
|
65
|
-
formatter.formatter.template.should.equal('xx xxx xxx xxxx')
|
|
69
|
+
// formatter.formatter.template.should.equal('xx xxx xxx xxxx')
|
|
70
|
+
formatter.formatter.template.should.equal('xx xxx xxxx')
|
|
66
71
|
// Hasn't yet started formatting the phone number using the template.
|
|
67
|
-
formatter.formatter.populatedNationalNumberTemplate.should.equal('xxx xxx xxxx')
|
|
72
|
+
// formatter.formatter.populatedNationalNumberTemplate.should.equal('xxx xxx xxxx')
|
|
73
|
+
formatter.formatter.populatedNationalNumberTemplate.should.equal('xxx xxxx')
|
|
68
74
|
// Has some national number digits, starts formatting the phone number using the template.
|
|
69
75
|
formatter.input('213')
|
|
70
76
|
formatter.formatter.populatedNationalNumberTemplate.should.equal('213 xxx xxxx')
|
|
@@ -1337,6 +1343,19 @@ describe('AsYouType.getNumberValue()', () => {
|
|
|
1337
1343
|
})
|
|
1338
1344
|
formatter.input('1').should.equal('1')
|
|
1339
1345
|
})
|
|
1346
|
+
|
|
1347
|
+
it('should work for SK phone numbers', function() {
|
|
1348
|
+
// There was a bug: "leading digits" `"2"` matched "leading digits pattern" `"90"`.
|
|
1349
|
+
// The incorrect `.match()` function result was `{ oveflow: true }`
|
|
1350
|
+
// while it should've been `undefined`.
|
|
1351
|
+
// https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/66
|
|
1352
|
+
const formatter = new AsYouType('SK')
|
|
1353
|
+
formatter.input('090').should.equal('090')
|
|
1354
|
+
formatter.reset()
|
|
1355
|
+
formatter.input('080').should.equal('080')
|
|
1356
|
+
formatter.reset()
|
|
1357
|
+
formatter.input('059').should.equal('059')
|
|
1358
|
+
})
|
|
1340
1359
|
})
|
|
1341
1360
|
|
|
1342
1361
|
function type(something) {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
character,
|
|
3
|
+
MatchTree
|
|
4
|
+
} from './AsYouTypeFormatter.PatternParser'
|
|
5
|
+
|
|
6
|
+
interface MatchOptions {
|
|
7
|
+
allowOverflow?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// An "overflow" match is when the string matches the pattern
|
|
11
|
+
// and there're still some characters left in it.
|
|
12
|
+
//
|
|
13
|
+
// For example, "12345" matches "12[0-5]|78" pattern with an overflow
|
|
14
|
+
// because "123" matches the "12[0-5]" variant of the pattern
|
|
15
|
+
// and there're still "45" characters left.
|
|
16
|
+
//
|
|
17
|
+
// This type of match is only returned when `allowOverflow` option is `true`.
|
|
18
|
+
// By default, `allowOverflow` is `false` and `undefined` ("no match" result)
|
|
19
|
+
// is returned in case of an "overflow" match.
|
|
20
|
+
//
|
|
21
|
+
interface MatchResultOverflow {
|
|
22
|
+
overflow: true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// When there's a ("full") match, returns a match result.
|
|
26
|
+
//
|
|
27
|
+
// A ("full") match is when the string matches the entire pattern.
|
|
28
|
+
//
|
|
29
|
+
// For example, "123" fully matches "12[0-5]|78" pattern.
|
|
30
|
+
//
|
|
31
|
+
interface MatchResultFullMatch {
|
|
32
|
+
match: true;
|
|
33
|
+
matchedChars: character[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// When there's a "partial" match, returns a "partial" match result.
|
|
37
|
+
//
|
|
38
|
+
// A "partial" match is when the string is not long enough
|
|
39
|
+
// to match the whole matching tree.
|
|
40
|
+
//
|
|
41
|
+
// For example, "123" is a partial match for "12[0-5]4|78" pattern,
|
|
42
|
+
// because "123" matched the "12[0-5]" part and the "4" part of the pattern
|
|
43
|
+
// is left uninvolved.
|
|
44
|
+
//
|
|
45
|
+
interface MatchResultPartialMatch {
|
|
46
|
+
partialMatch: true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// When there's no match, returns `undefined`.
|
|
50
|
+
//
|
|
51
|
+
// For example, "123" doesn't match "456|789" pattern.
|
|
52
|
+
//
|
|
53
|
+
type MatchResultNoMatch = undefined;
|
|
54
|
+
|
|
55
|
+
type MatchResult =
|
|
56
|
+
MatchResultOverflow |
|
|
57
|
+
MatchResultFullMatch |
|
|
58
|
+
MatchResultPartialMatch |
|
|
59
|
+
MatchResultNoMatch;
|
|
60
|
+
|
|
61
|
+
export default class PatternMatcher {
|
|
62
|
+
constructor(pattern: string);
|
|
63
|
+
match(string: string, options?: MatchOptions): MatchResult;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function match(characters: character[], tree: MatchTree, last?: boolean);
|