libphonenumber-js 1.12.10 → 1.12.12

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