libphonenumber-js 1.12.10 → 1.12.11

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