libphonenumber-js 1.10.4 → 1.10.7

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.
Files changed (129) hide show
  1. package/README.md +35 -9
  2. package/build/AsYouType.test.js +26 -8
  3. package/build/AsYouType.test.js.map +1 -1
  4. package/build/AsYouTypeFormatter.PatternMatcher.js +36 -224
  5. package/build/AsYouTypeFormatter.PatternMatcher.js.map +1 -1
  6. package/build/AsYouTypeFormatter.PatternMatcher.test.js +9 -0
  7. package/build/AsYouTypeFormatter.PatternMatcher.test.js.map +1 -1
  8. package/build/AsYouTypeFormatter.PatternParser.js +241 -0
  9. package/build/AsYouTypeFormatter.PatternParser.js.map +1 -0
  10. package/build/AsYouTypeFormatter.PatternParser.test.js +49 -0
  11. package/build/AsYouTypeFormatter.PatternParser.test.js.map +1 -0
  12. package/build/AsYouTypeFormatter.js.map +1 -1
  13. package/build/package.json +5 -1
  14. package/bundle/libphonenumber-js.min.js +1 -1
  15. package/bundle/libphonenumber-js.min.js.map +1 -1
  16. package/bundle/libphonenumber-max.js +1 -1
  17. package/bundle/libphonenumber-max.js.map +1 -1
  18. package/bundle/libphonenumber-min.js +1 -1
  19. package/bundle/libphonenumber-min.js.map +1 -1
  20. package/bundle/libphonenumber-mobile.js +1 -1
  21. package/bundle/libphonenumber-mobile.js.map +1 -1
  22. package/core/package.json +1 -2
  23. package/es6/AsYouType.test.js +26 -8
  24. package/es6/AsYouType.test.js.map +1 -1
  25. package/es6/AsYouTypeFormatter.PatternMatcher.js +33 -223
  26. package/es6/AsYouTypeFormatter.PatternMatcher.js.map +1 -1
  27. package/es6/AsYouTypeFormatter.PatternMatcher.test.js +9 -0
  28. package/es6/AsYouTypeFormatter.PatternMatcher.test.js.map +1 -1
  29. package/es6/AsYouTypeFormatter.PatternParser.js +234 -0
  30. package/es6/AsYouTypeFormatter.PatternParser.js.map +1 -0
  31. package/es6/AsYouTypeFormatter.PatternParser.test.js +44 -0
  32. package/es6/AsYouTypeFormatter.PatternParser.test.js.map +1 -0
  33. package/es6/AsYouTypeFormatter.js.map +1 -1
  34. package/index.cjs +9 -9
  35. package/index.cjs.js +9 -9
  36. package/index.es6.exports/PhoneNumberSearch.js +3 -1
  37. package/index.es6.exports/findPhoneNumbers.js +2 -2
  38. package/index.es6.exports/format.js +2 -2
  39. package/index.es6.exports/getNumberType.js +2 -2
  40. package/index.es6.exports/isPossibleNumber.js +2 -2
  41. package/index.es6.exports/isValidNumber.js +2 -2
  42. package/index.es6.exports/isValidNumberForRegion.js +2 -2
  43. package/index.es6.exports/parse.js +2 -2
  44. package/index.es6.exports/searchPhoneNumbers.js +2 -2
  45. package/max/exports/AsYouType.js +4 -1
  46. package/max/exports/Metadata.js +4 -1
  47. package/max/exports/PhoneNumberMatcher.js +4 -1
  48. package/max/exports/findNumbers.js +2 -2
  49. package/max/exports/findPhoneNumbersInText.js +2 -2
  50. package/max/exports/formatIncompletePhoneNumber.js +2 -2
  51. package/max/exports/getCountries.js +2 -2
  52. package/max/exports/getCountryCallingCode.js +2 -2
  53. package/max/exports/getExampleNumber.js +2 -2
  54. package/max/exports/getExtPrefix.js +2 -2
  55. package/max/exports/isPossiblePhoneNumber.js +2 -2
  56. package/max/exports/isSupportedCountry.js +2 -2
  57. package/max/exports/isValidPhoneNumber.js +2 -2
  58. package/max/exports/parsePhoneNumberFromString.js +2 -2
  59. package/max/exports/parsePhoneNumberWithError.js +2 -2
  60. package/max/exports/searchNumbers.js +2 -2
  61. package/max/exports/searchPhoneNumbersInText.js +2 -2
  62. package/max/exports/validatePhoneNumberLength.js +2 -2
  63. package/max/exports/withMetadataArgument.js +9 -0
  64. package/max/metadata/package.json +16 -0
  65. package/max/package.json +1 -2
  66. package/metadata.full.json +1 -1
  67. package/metadata.full.json.js +1 -1
  68. package/metadata.max.json +1 -1
  69. package/metadata.max.json.js +1 -1
  70. package/metadata.min.json +1 -1
  71. package/metadata.min.json.js +1 -1
  72. package/metadata.mobile.json +1 -1
  73. package/metadata.mobile.json.js +1 -1
  74. package/min/exports/AsYouType.js +4 -1
  75. package/min/exports/Metadata.js +4 -1
  76. package/min/exports/PhoneNumberMatcher.js +4 -1
  77. package/min/exports/findNumbers.js +2 -2
  78. package/min/exports/findPhoneNumbersInText.js +2 -2
  79. package/min/exports/formatIncompletePhoneNumber.js +2 -2
  80. package/min/exports/getCountries.js +2 -2
  81. package/min/exports/getCountryCallingCode.js +2 -2
  82. package/min/exports/getExampleNumber.js +2 -2
  83. package/min/exports/getExtPrefix.js +2 -2
  84. package/min/exports/isPossiblePhoneNumber.js +2 -2
  85. package/min/exports/isSupportedCountry.js +2 -2
  86. package/min/exports/isValidPhoneNumber.js +2 -2
  87. package/min/exports/parsePhoneNumberFromString.js +2 -2
  88. package/min/exports/parsePhoneNumberWithError.js +2 -2
  89. package/min/exports/searchNumbers.js +2 -2
  90. package/min/exports/searchPhoneNumbersInText.js +2 -2
  91. package/min/exports/validatePhoneNumberLength.js +2 -2
  92. package/min/exports/withMetadataArgument.js +9 -0
  93. package/min/metadata/package.json +16 -0
  94. package/min/package.json +1 -2
  95. package/mobile/examples/package.json +16 -0
  96. package/mobile/exports/AsYouType.js +4 -1
  97. package/mobile/exports/Metadata.js +4 -1
  98. package/mobile/exports/PhoneNumberMatcher.js +4 -1
  99. package/mobile/exports/findNumbers.js +2 -2
  100. package/mobile/exports/findPhoneNumbersInText.js +2 -2
  101. package/mobile/exports/formatIncompletePhoneNumber.js +2 -2
  102. package/mobile/exports/getCountries.js +2 -2
  103. package/mobile/exports/getCountryCallingCode.js +2 -2
  104. package/mobile/exports/getExampleNumber.js +2 -2
  105. package/mobile/exports/getExtPrefix.js +2 -2
  106. package/mobile/exports/isPossiblePhoneNumber.js +2 -2
  107. package/mobile/exports/isSupportedCountry.js +2 -2
  108. package/mobile/exports/isValidPhoneNumber.js +2 -2
  109. package/mobile/exports/parsePhoneNumberFromString.js +2 -2
  110. package/mobile/exports/parsePhoneNumberWithError.js +2 -2
  111. package/mobile/exports/searchNumbers.js +2 -2
  112. package/mobile/exports/searchPhoneNumbersInText.js +2 -2
  113. package/mobile/exports/validatePhoneNumberLength.js +2 -2
  114. package/mobile/exports/withMetadataArgument.js +9 -0
  115. package/mobile/metadata/package.json +16 -0
  116. package/mobile/package.json +1 -2
  117. package/package.json +22 -2
  118. package/runnable/create-commonjs-package-json.js +1 -1
  119. package/source/AsYouType.test.js +25 -6
  120. package/source/AsYouTypeFormatter.PatternMatcher.d.ts +66 -0
  121. package/source/AsYouTypeFormatter.PatternMatcher.js +30 -206
  122. package/source/AsYouTypeFormatter.PatternMatcher.test.js +8 -0
  123. package/source/AsYouTypeFormatter.PatternParser.d.ts +58 -0
  124. package/source/AsYouTypeFormatter.PatternParser.js +214 -0
  125. package/source/AsYouTypeFormatter.PatternParser.test.js +67 -0
  126. package/source/AsYouTypeFormatter.js +2 -0
  127. package/max/metadata.js +0 -11
  128. package/min/metadata.js +0 -11
  129. package/mobile/metadata.js +0 -11
@@ -1,4 +1,7 @@
1
- import metadata from '../metadata.js'
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) {
@@ -1,4 +1,7 @@
1
- import metadata from '../metadata.js'
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
- import metadata from '../metadata.js'
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 { withMetadata } from '../metadata.js'
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 withMetadata(_findNumbers, arguments)
5
+ return withMetadataArgument(_findNumbers, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_findPhoneNumbersInText, arguments)
5
+ return withMetadataArgument(_findPhoneNumbersInText, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_formatIncompletePhoneNumber, arguments)
5
+ return withMetadataArgument(_formatIncompletePhoneNumber, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_getCountries, arguments)
5
+ return withMetadataArgument(_getCountries, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_getCountryCallingCode, arguments)
5
+ return withMetadataArgument(_getCountryCallingCode, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_getExampleNumber, arguments)
5
+ return withMetadataArgument(_getExampleNumber, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_getExtPrefix, arguments)
5
+ return withMetadataArgument(_getExtPrefix, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_isPossiblePhoneNumber, arguments)
5
+ return withMetadataArgument(_isPossiblePhoneNumber, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_isSupportedCountry, arguments)
5
+ return withMetadataArgument(_isSupportedCountry, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_isValidPhoneNumber, arguments)
5
+ return withMetadataArgument(_isValidPhoneNumber, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_parsePhoneNumberFromString, arguments)
5
+ return withMetadataArgument(_parsePhoneNumberFromString, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_parsePhoneNumberWithError, arguments)
5
+ return withMetadataArgument(_parsePhoneNumberWithError, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_searchNumbers, arguments)
5
+ return withMetadataArgument(_searchNumbers, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_searchPhoneNumbersInText, arguments)
5
+ return withMetadataArgument(_searchPhoneNumbersInText, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_validatePhoneNumberLength, arguments)
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
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "private": true,
3
+ "name": "libphonenumber-js/min/metadata",
4
+ "main": "../../metadata.min.json",
5
+ "module": "../../metadata.min.json.js",
6
+ "types": "../../metadata.min.json.d.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "../../metadata.min.json.d.ts",
11
+ "import": "../../metadata.min.json.js",
12
+ "require": "../../metadata.min.json"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
package/min/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "private": true,
3
- "name": "libphonenumber-js-min",
4
- "version": "1.0.0",
3
+ "name": "libphonenumber-js/min",
5
4
  "main": "index.cjs",
6
5
  "module": "index.js",
7
6
  "type": "module",
@@ -0,0 +1,16 @@
1
+ {
2
+ "private": true,
3
+ "name": "libphonenumber-js/mobile/examples",
4
+ "main": "../../examples.mobile.json",
5
+ "module": "../../examples.mobile.json.js",
6
+ "types": "../../examples.mobile.json.d.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "../../examples.mobile.json.d.ts",
11
+ "import": "../../examples.mobile.json.js",
12
+ "require": "../../examples.mobile.json"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
@@ -1,4 +1,7 @@
1
- import metadata from '../metadata.js'
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
- import metadata from '../metadata.js'
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
- import metadata from '../metadata.js'
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 { withMetadata } from '../metadata.js'
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 withMetadata(_findNumbers, arguments)
5
+ return withMetadataArgument(_findNumbers, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_findPhoneNumbersInText, arguments)
5
+ return withMetadataArgument(_findPhoneNumbersInText, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_formatIncompletePhoneNumber, arguments)
5
+ return withMetadataArgument(_formatIncompletePhoneNumber, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_getCountries, arguments)
5
+ return withMetadataArgument(_getCountries, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_getCountryCallingCode, arguments)
5
+ return withMetadataArgument(_getCountryCallingCode, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_getExampleNumber, arguments)
5
+ return withMetadataArgument(_getExampleNumber, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_getExtPrefix, arguments)
5
+ return withMetadataArgument(_getExtPrefix, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_isPossiblePhoneNumber, arguments)
5
+ return withMetadataArgument(_isPossiblePhoneNumber, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_isSupportedCountry, arguments)
5
+ return withMetadataArgument(_isSupportedCountry, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_isValidPhoneNumber, arguments)
5
+ return withMetadataArgument(_isValidPhoneNumber, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_parsePhoneNumberFromString, arguments)
5
+ return withMetadataArgument(_parsePhoneNumberFromString, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_parsePhoneNumberWithError, arguments)
5
+ return withMetadataArgument(_parsePhoneNumberWithError, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_searchNumbers, arguments)
5
+ return withMetadataArgument(_searchNumbers, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_searchPhoneNumbersInText, arguments)
5
+ return withMetadataArgument(_searchPhoneNumbersInText, arguments)
6
6
  }
@@ -1,6 +1,6 @@
1
- import { withMetadata } from '../metadata.js'
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 withMetadata(_validatePhoneNumberLength, arguments)
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
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "private": true,
3
+ "name": "libphonenumber-js/mobile/metadata",
4
+ "main": "../../metadata.mobile.json",
5
+ "module": "../../metadata.mobile.json.js",
6
+ "types": "../../metadata.mobile.json.d.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "../../metadata.mobile.json.d.ts",
11
+ "import": "../../metadata.mobile.json.js",
12
+ "require": "../../metadata.mobile.json"
13
+ }
14
+ },
15
+ "sideEffects": false
16
+ }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "private": true,
3
- "name": "libphonenumber-js-mobile",
4
- "version": "1.0.0",
3
+ "name": "libphonenumber-js/mobile",
5
4
  "main": "index.cjs",
6
5
  "module": "index.js",
7
6
  "types": "../min/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libphonenumber-js",
3
- "version": "1.10.4",
3
+ "version": "1.10.7",
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",
@@ -31,6 +31,11 @@
31
31
  "import": "./core/index.js",
32
32
  "require": "./core/index.cjs"
33
33
  },
34
+ "./min/metadata": {
35
+ "types": "./metadata.min.json.d.ts",
36
+ "import": "./metadata.min.json.js",
37
+ "require": "./metadata.min.json"
38
+ },
34
39
  "./metadata.min": {
35
40
  "types": "./metadata.min.json.d.ts",
36
41
  "import": "./metadata.min.json.js",
@@ -51,6 +56,11 @@
51
56
  "import": "./metadata.max.json.js",
52
57
  "require": "./metadata.max.json"
53
58
  },
59
+ "./max/metadata": {
60
+ "types": "./metadata.max.json.d.ts",
61
+ "import": "./metadata.max.json.js",
62
+ "require": "./metadata.max.json"
63
+ },
54
64
  "./metadata.max": {
55
65
  "types": "./metadata.max.json.d.ts",
56
66
  "import": "./metadata.max.json.js",
@@ -61,6 +71,11 @@
61
71
  "import": "./metadata.max.json.js",
62
72
  "require": "./metadata.max.json"
63
73
  },
74
+ "./mobile/metadata": {
75
+ "types": "./metadata.mobile.json.d.ts",
76
+ "import": "./metadata.mobile.json.js",
77
+ "require": "./metadata.mobile.json"
78
+ },
64
79
  "./metadata.mobile": {
65
80
  "types": "./metadata.mobile.json.d.ts",
66
81
  "import": "./metadata.mobile.json.js",
@@ -71,6 +86,11 @@
71
86
  "import": "./metadata.mobile.json.js",
72
87
  "require": "./metadata.mobile.json"
73
88
  },
89
+ "./mobile/examples": {
90
+ "types": "./examples.mobile.json.d.ts",
91
+ "import": "./examples.mobile.json.js",
92
+ "require": "./examples.mobile.json"
93
+ },
74
94
  "./examples.mobile": {
75
95
  "types": "./examples.mobile.json.d.ts",
76
96
  "import": "./examples.mobile.json.js",
@@ -129,7 +149,7 @@
129
149
  "generate-country-codes": "node --experimental-json-modules runnable/generate-country-codes",
130
150
  "test": "node --experimental-json-modules node_modules/mocha/bin/_mocha --colors --bail --reporter spec --require ./test/setup.js \"source/**/*.test.js\" \"test/**/*.test.js\" --recursive",
131
151
  "test-coverage": "npm-run-all build:commonjs test-coverage:commonjs",
132
- "test-coverage:commonjs": "node --experimental-json-modules node_modules/istanbul/lib/cli.js cover -x \"es6/**\" -x \"*.test.js\" -x \"build/findNumbers/Leniency.js\" -x \"build/findNumbers/RegExpCache.js\" -x \"build/findNumbers/LRUCache.js\" -x \"build/PhoneNumberMatcher.js\" -x \"build/tools/semver-compare.js\" node_modules/mocha/bin/_mocha -- --colors --reporter dot --require ./test/setup.js \"build/**/*.test.js\" --recursive",
152
+ "test-coverage:commonjs": "node --experimental-json-modules node_modules/istanbul/lib/cli.js cover -x \"*.test.js\" -x \"build/findNumbers/Leniency.js\" -x \"build/findNumbers/RegExpCache.js\" -x \"build/findNumbers/LRUCache.js\" -x \"build/PhoneNumberMatcher.js\" -x \"build/tools/semver-compare.js\" node_modules/mocha/bin/_mocha -- --colors --reporter dot --require ./test/setup.js \"build/**/*.test.js\" --recursive",
133
153
  "test-coverage--does-not-work-with-es-modules": "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/RegExpCache.js\" -x \"source/findNumbers/LRUCache.js\" -x \"source/PhoneNumberMatcher.js\" -x \"source/tools/semver-compare.js\" node_modules/mocha/bin/_mocha -- --colors --reporter dot --require ./test/setup.js \"source/**/*.test.js\" \"test/**/*.test.js\" --recursive",
134
154
  "test-coverage--nyc--does-not-work-with-es-modules": "cross-env nyc node --experimental-json-modules node_modules/mocha/bin/_mocha --bail --require @babel/register --require ./test/setup.js \"source/**/*.test.js\" \"test/**/*.test.js\"",
135
155
  "coveralls--nyc-is-very-slow-and-is-not-used": "nyc report --reporter=text-lcov | coveralls",
@@ -8,4 +8,4 @@ fs.writeFileSync('./build/package.json', JSON.stringify({
8
8
  name: 'libphonenumber-js/build',
9
9
  type: 'commonjs',
10
10
  private: true
11
- }), 'utf8')
11
+ }, null, 2), 'utf8')
@@ -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.populatedNationalNumberTemplate.should.equal('1 (xxx) xxx-xxxx')
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.populatedNationalNumberTemplate.should.equal('xxx xxx xxxx')
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) {