libphonenumber-js 1.10.21 → 1.10.22

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 (364) hide show
  1. package/README.md +107 -24
  2. package/build/PhoneNumber.js +54 -34
  3. package/build/PhoneNumber.js.map +1 -1
  4. package/build/PhoneNumber.test.js +7 -1
  5. package/build/PhoneNumber.test.js.map +1 -1
  6. package/build/PhoneNumberMatcher.js +2 -2
  7. package/build/PhoneNumberMatcher.js.map +1 -1
  8. package/build/findNumbers/Leniency.js +4 -4
  9. package/build/findNumbers/Leniency.js.map +1 -1
  10. package/build/findPhoneNumbersInText.js +16 -48
  11. package/build/findPhoneNumbersInText.js.map +1 -1
  12. package/build/findPhoneNumbersInText.test.js +238 -0
  13. package/build/findPhoneNumbersInText.test.js.map +1 -1
  14. package/build/format.js +174 -96
  15. package/build/format.js.map +1 -1
  16. package/build/format.test.js +81 -39
  17. package/build/format.test.js.map +1 -1
  18. package/build/{formatNumberForMobileDialing.js → formatPhoneNumberForMobileDialing.js} +8 -8
  19. package/build/formatPhoneNumberForMobileDialing.js.map +1 -0
  20. package/build/formatPhoneNumberForMobileDialing.test.js +15 -0
  21. package/build/formatPhoneNumberForMobileDialing.test.js.map +1 -0
  22. package/build/helpers/getNumberType.test.js.map +1 -1
  23. package/build/{isPossibleNumber_.js → isPossible.js} +14 -1
  24. package/build/isPossible.js.map +1 -0
  25. package/build/isPossible.test.js +117 -0
  26. package/build/isPossible.test.js.map +1 -0
  27. package/build/isPossiblePhoneNumber.js +4 -4
  28. package/build/isPossiblePhoneNumber.js.map +1 -1
  29. package/build/{validate_.js → isValid.js} +17 -9
  30. package/build/isValid.js.map +1 -0
  31. package/build/isValid.test.js +138 -0
  32. package/build/isValid.test.js.map +1 -0
  33. package/build/isValidPhoneNumber.js +4 -4
  34. package/build/isValidPhoneNumber.js.map +1 -1
  35. package/build/legacy/findNumbers.js +29 -0
  36. package/build/legacy/findNumbers.js.map +1 -0
  37. package/build/{findNumbers.test.js → legacy/findNumbers.test.js} +1 -1
  38. package/build/legacy/findNumbers.test.js.map +1 -0
  39. package/build/{findPhoneNumbers.js → legacy/findPhoneNumbers.js} +8 -6
  40. package/build/legacy/findPhoneNumbers.js.map +1 -0
  41. package/build/{findPhoneNumbers.test.js → legacy/findPhoneNumbers.test.js} +5 -5
  42. package/build/legacy/findPhoneNumbers.test.js.map +1 -0
  43. package/build/{findPhoneNumbers_.js → legacy/findPhoneNumbersInitialImplementation.js} +9 -9
  44. package/build/legacy/findPhoneNumbersInitialImplementation.js.map +1 -0
  45. package/build/legacy/format.js +128 -0
  46. package/build/legacy/format.js.map +1 -0
  47. package/build/legacy/format.test.js +284 -0
  48. package/build/legacy/format.test.js.map +1 -0
  49. package/build/{getNumberType.js → legacy/getNumberType.js} +11 -6
  50. package/build/legacy/getNumberType.js.map +1 -0
  51. package/build/{getNumberType.test.js → legacy/getNumberType.test.js} +2 -2
  52. package/build/legacy/getNumberType.test.js.map +1 -0
  53. package/build/{isPossibleNumber.js → legacy/isPossibleNumber.js} +8 -3
  54. package/build/legacy/isPossibleNumber.js.map +1 -0
  55. package/build/{isPossibleNumber.test.js → legacy/isPossibleNumber.test.js} +1 -1
  56. package/build/legacy/isPossibleNumber.test.js.map +1 -0
  57. package/build/{validate.js → legacy/isValidNumber.js} +9 -4
  58. package/build/legacy/isValidNumber.js.map +1 -0
  59. package/build/{validate.test.js → legacy/isValidNumber.test.js} +10 -7
  60. package/build/legacy/isValidNumber.test.js.map +1 -0
  61. package/build/legacy/isValidNumberForRegion.js +79 -0
  62. package/build/legacy/isValidNumberForRegion.js.map +1 -0
  63. package/build/{isValidNumberForRegion.test.js → legacy/isValidNumberForRegion.test.js} +1 -1
  64. package/build/legacy/isValidNumberForRegion.test.js.map +1 -0
  65. package/build/{isValidNumberForRegion_.js → legacy/isValidNumberForRegion_.js} +2 -2
  66. package/build/legacy/isValidNumberForRegion_.js.map +1 -0
  67. package/build/legacy/parse.js +22 -0
  68. package/build/legacy/parse.js.map +1 -0
  69. package/build/legacy/parse.test.js +568 -0
  70. package/build/legacy/parse.test.js.map +1 -0
  71. package/build/{searchNumbers.js → legacy/searchNumbers.js} +3 -3
  72. package/build/legacy/searchNumbers.js.map +1 -0
  73. package/build/{searchNumbers.test.js → legacy/searchNumbers.test.js} +1 -1
  74. package/build/legacy/searchNumbers.test.js.map +1 -0
  75. package/build/normalizeArguments.js +89 -0
  76. package/build/normalizeArguments.js.map +1 -0
  77. package/build/parse.js +358 -24
  78. package/build/parse.js.map +1 -1
  79. package/build/parse.test.js +28 -8
  80. package/build/parse.test.js.map +1 -1
  81. package/build/parsePhoneNumber.js +3 -80
  82. package/build/parsePhoneNumber.js.map +1 -1
  83. package/build/parsePhoneNumber.test.js +63 -113
  84. package/build/parsePhoneNumber.test.js.map +1 -1
  85. package/build/parsePhoneNumberWithError.js +22 -0
  86. package/build/parsePhoneNumberWithError.js.map +1 -0
  87. package/build/parsePhoneNumberWithError.test.js +142 -0
  88. package/build/parsePhoneNumberWithError.test.js.map +1 -0
  89. package/{es6/parsePhoneNumberFromString_.js → build/parsePhoneNumberWithError_.js} +16 -22
  90. package/build/parsePhoneNumberWithError_.js.map +1 -0
  91. package/build/parsePhoneNumber_.js +22 -4
  92. package/build/parsePhoneNumber_.js.map +1 -1
  93. package/build/searchPhoneNumbersInText.js +33 -5
  94. package/build/searchPhoneNumbersInText.js.map +1 -1
  95. package/build/searchPhoneNumbersInText.test.js +24 -0
  96. package/build/searchPhoneNumbersInText.test.js.map +1 -1
  97. package/build/validatePhoneNumberLength.js +4 -4
  98. package/build/validatePhoneNumberLength.js.map +1 -1
  99. package/bundle/libphonenumber-js.min.js +1 -1
  100. package/bundle/libphonenumber-js.min.js.map +1 -1
  101. package/bundle/libphonenumber-max.js +1 -1
  102. package/bundle/libphonenumber-max.js.map +1 -1
  103. package/bundle/libphonenumber-min.js +1 -1
  104. package/bundle/libphonenumber-min.js.map +1 -1
  105. package/bundle/libphonenumber-mobile.js +1 -1
  106. package/bundle/libphonenumber-mobile.js.map +1 -1
  107. package/core/index.cjs +5 -4
  108. package/core/index.cjs.js +5 -4
  109. package/core/index.js +4 -5
  110. package/custom.js +17 -18
  111. package/es6/PhoneNumber.js +50 -28
  112. package/es6/PhoneNumber.js.map +1 -1
  113. package/es6/PhoneNumber.test.js +7 -1
  114. package/es6/PhoneNumber.test.js.map +1 -1
  115. package/es6/PhoneNumberMatcher.js +1 -1
  116. package/es6/PhoneNumberMatcher.js.map +1 -1
  117. package/es6/findNumbers/Leniency.js +1 -1
  118. package/es6/findNumbers/Leniency.js.map +1 -1
  119. package/es6/findPhoneNumbersInText.js +17 -47
  120. package/es6/findPhoneNumbersInText.js.map +1 -1
  121. package/es6/findPhoneNumbersInText.test.js +238 -0
  122. package/es6/findPhoneNumbersInText.test.js.map +1 -1
  123. package/es6/format.js +170 -96
  124. package/es6/format.js.map +1 -1
  125. package/es6/format.test.js +82 -41
  126. package/es6/format.test.js.map +1 -1
  127. package/es6/{formatNumberForMobileDialing.js → formatPhoneNumberForMobileDialing.js} +3 -3
  128. package/es6/formatPhoneNumberForMobileDialing.js.map +1 -0
  129. package/es6/formatPhoneNumberForMobileDialing.test.js +14 -0
  130. package/es6/formatPhoneNumberForMobileDialing.test.js.map +1 -0
  131. package/es6/helpers/getNumberType.test.js.map +1 -1
  132. package/es6/{isPossibleNumber_.js → isPossible.js} +15 -1
  133. package/es6/isPossible.js.map +1 -0
  134. package/es6/isPossible.test.js +111 -0
  135. package/es6/isPossible.test.js.map +1 -0
  136. package/es6/isPossiblePhoneNumber.js +3 -3
  137. package/es6/isPossiblePhoneNumber.js.map +1 -1
  138. package/es6/{validate_.js → isValid.js} +17 -9
  139. package/es6/isValid.js.map +1 -0
  140. package/es6/isValid.test.js +132 -0
  141. package/es6/isValid.test.js.map +1 -0
  142. package/es6/isValidPhoneNumber.js +3 -3
  143. package/es6/isValidPhoneNumber.js.map +1 -1
  144. package/es6/legacy/findNumbers.js +18 -0
  145. package/es6/legacy/findNumbers.js.map +1 -0
  146. package/es6/{findNumbers.test.js → legacy/findNumbers.test.js} +1 -1
  147. package/es6/legacy/findNumbers.test.js.map +1 -0
  148. package/es6/{findPhoneNumbers.js → legacy/findPhoneNumbers.js} +2 -2
  149. package/es6/legacy/findPhoneNumbers.js.map +1 -0
  150. package/es6/{findPhoneNumbers.test.js → legacy/findPhoneNumbers.test.js} +2 -2
  151. package/es6/legacy/findPhoneNumbers.test.js.map +1 -0
  152. package/es6/{findPhoneNumbers_.js → legacy/findPhoneNumbersInitialImplementation.js} +8 -8
  153. package/es6/legacy/findPhoneNumbersInitialImplementation.js.map +1 -0
  154. package/es6/legacy/format.js +116 -0
  155. package/es6/legacy/format.js.map +1 -0
  156. package/es6/legacy/format.test.js +279 -0
  157. package/es6/legacy/format.test.js.map +1 -0
  158. package/es6/{getNumberType.js → legacy/getNumberType.js} +9 -4
  159. package/es6/legacy/getNumberType.js.map +1 -0
  160. package/es6/{getNumberType.test.js → legacy/getNumberType.test.js} +2 -2
  161. package/es6/legacy/getNumberType.test.js.map +1 -0
  162. package/es6/{isPossibleNumber.js → legacy/isPossibleNumber.js} +7 -2
  163. package/es6/legacy/isPossibleNumber.js.map +1 -0
  164. package/es6/{isPossibleNumber.test.js → legacy/isPossibleNumber.test.js} +1 -1
  165. package/es6/legacy/isPossibleNumber.test.js.map +1 -0
  166. package/es6/{validate.js → legacy/isValidNumber.js} +8 -3
  167. package/es6/legacy/isValidNumber.js.map +1 -0
  168. package/es6/{validate.test.js → legacy/isValidNumber.test.js} +8 -5
  169. package/es6/legacy/isValidNumber.test.js.map +1 -0
  170. package/es6/legacy/isValidNumberForRegion.js +67 -0
  171. package/es6/legacy/isValidNumberForRegion.js.map +1 -0
  172. package/es6/{isValidNumberForRegion.test.js → legacy/isValidNumberForRegion.test.js} +1 -1
  173. package/es6/legacy/isValidNumberForRegion.test.js.map +1 -0
  174. package/es6/{isValidNumberForRegion_.js → legacy/isValidNumberForRegion_.js} +1 -1
  175. package/es6/legacy/isValidNumberForRegion_.js.map +1 -0
  176. package/es6/legacy/parse.js +11 -0
  177. package/es6/legacy/parse.js.map +1 -0
  178. package/es6/legacy/parse.test.js +562 -0
  179. package/es6/legacy/parse.test.js.map +1 -0
  180. package/es6/{searchNumbers.js → legacy/searchNumbers.js} +2 -2
  181. package/es6/legacy/searchNumbers.js.map +1 -0
  182. package/es6/{searchNumbers.test.js → legacy/searchNumbers.test.js} +1 -1
  183. package/es6/legacy/searchNumbers.test.js.map +1 -0
  184. package/es6/normalizeArguments.js +81 -0
  185. package/es6/normalizeArguments.js.map +1 -0
  186. package/es6/parse.js +336 -22
  187. package/es6/parse.js.map +1 -1
  188. package/es6/parse.test.js +28 -8
  189. package/es6/parse.test.js.map +1 -1
  190. package/es6/parsePhoneNumber.js +1 -76
  191. package/es6/parsePhoneNumber.js.map +1 -1
  192. package/es6/parsePhoneNumber.test.js +63 -112
  193. package/es6/parsePhoneNumber.test.js.map +1 -1
  194. package/es6/parsePhoneNumberWithError.js +11 -0
  195. package/es6/parsePhoneNumberWithError.js.map +1 -0
  196. package/es6/parsePhoneNumberWithError.test.js +136 -0
  197. package/es6/parsePhoneNumberWithError.test.js.map +1 -0
  198. package/{build/parsePhoneNumberFromString_.js → es6/parsePhoneNumberWithError_.js} +6 -34
  199. package/es6/parsePhoneNumberWithError_.js.map +1 -0
  200. package/es6/parsePhoneNumber_.js +20 -4
  201. package/es6/parsePhoneNumber_.js.map +1 -1
  202. package/es6/searchPhoneNumbersInText.js +33 -5
  203. package/es6/searchPhoneNumbersInText.js.map +1 -1
  204. package/es6/searchPhoneNumbersInText.test.js +24 -0
  205. package/es6/searchPhoneNumbersInText.test.js.map +1 -1
  206. package/es6/validatePhoneNumberLength.js +3 -3
  207. package/es6/validatePhoneNumberLength.js.map +1 -1
  208. package/index.cjs +9 -9
  209. package/index.cjs.js +9 -9
  210. package/index.es6.exports/PhoneNumberSearch.js +1 -1
  211. package/index.es6.exports/findPhoneNumbers.js +1 -1
  212. package/index.es6.exports/format.js +1 -1
  213. package/index.es6.exports/getNumberType.js +1 -1
  214. package/index.es6.exports/isPossibleNumber.js +1 -1
  215. package/index.es6.exports/isValidNumber.js +1 -1
  216. package/index.es6.exports/isValidNumberForRegion.js +1 -1
  217. package/index.es6.exports/parse.js +1 -1
  218. package/index.es6.exports/searchPhoneNumbers.js +1 -1
  219. package/index.js +8 -9
  220. package/max/exports/parsePhoneNumber.js +6 -0
  221. package/max/index.js +1 -2
  222. package/metadata.full.json +1 -1
  223. package/metadata.full.json.js +1 -1
  224. package/metadata.max.json +1 -1
  225. package/metadata.max.json.js +1 -1
  226. package/metadata.min.json +1 -1
  227. package/metadata.min.json.js +1 -1
  228. package/metadata.mobile.json +1 -1
  229. package/metadata.mobile.json.js +1 -1
  230. package/min/exports/parsePhoneNumber.js +6 -0
  231. package/min/index.js +1 -2
  232. package/mobile/exports/parsePhoneNumber.js +6 -0
  233. package/mobile/index.js +1 -2
  234. package/package.json +1 -1
  235. package/source/PhoneNumber.js +52 -26
  236. package/source/PhoneNumber.test.js +8 -0
  237. package/source/PhoneNumberMatcher.js +1 -1
  238. package/source/findNumbers/Leniency.js +1 -1
  239. package/source/findPhoneNumbersInText.js +10 -43
  240. package/source/findPhoneNumbersInText.test.js +220 -0
  241. package/source/format.js +167 -94
  242. package/source/format.test.js +54 -29
  243. package/source/{formatNumberForMobileDialing.js → formatPhoneNumberForMobileDialing.js} +2 -2
  244. package/source/formatPhoneNumberForMobileDialing.test.js +16 -0
  245. package/source/helpers/getNumberType.test.js +0 -1
  246. package/source/{isPossibleNumber_.js → isPossible.js} +13 -0
  247. package/source/isPossible.test.js +66 -0
  248. package/source/isPossiblePhoneNumber.js +3 -3
  249. package/source/{validate_.js → isValid.js} +16 -10
  250. package/source/isValid.test.js +116 -0
  251. package/source/isValidPhoneNumber.js +3 -3
  252. package/source/legacy/findNumbers.js +12 -0
  253. package/source/{findNumbers.test.js → legacy/findNumbers.test.js} +2 -2
  254. package/source/{findPhoneNumbers.js → legacy/findPhoneNumbers.js} +2 -2
  255. package/source/{findPhoneNumbers.test.js → legacy/findPhoneNumbers.test.js} +2 -2
  256. package/source/{findPhoneNumbers_.js → legacy/findPhoneNumbersInitialImplementation.js} +7 -7
  257. package/source/legacy/format.js +110 -0
  258. package/source/legacy/format.test.js +240 -0
  259. package/source/{getNumberType.js → legacy/getNumberType.js} +8 -5
  260. package/source/{getNumberType.test.js → legacy/getNumberType.test.js} +2 -2
  261. package/source/{isPossibleNumber.js → legacy/isPossibleNumber.js} +6 -3
  262. package/source/{isPossibleNumber.test.js → legacy/isPossibleNumber.test.js} +1 -1
  263. package/source/{validate.js → legacy/isValidNumber.js} +6 -3
  264. package/source/{validate.test.js → legacy/isValidNumber.test.js} +8 -3
  265. package/source/legacy/isValidNumberForRegion.js +62 -0
  266. package/source/{isValidNumberForRegion.test.js → legacy/isValidNumberForRegion.test.js} +1 -1
  267. package/source/{isValidNumberForRegion_.js → legacy/isValidNumberForRegion_.js} +1 -1
  268. package/source/legacy/parse.js +7 -0
  269. package/source/legacy/parse.test.js +524 -0
  270. package/source/{searchNumbers.js → legacy/searchNumbers.js} +2 -2
  271. package/source/{searchNumbers.test.js → legacy/searchNumbers.test.js} +1 -1
  272. package/source/normalizeArguments.js +57 -0
  273. package/source/parse.js +344 -22
  274. package/source/parse.test.js +19 -4
  275. package/source/parsePhoneNumber.js +1 -55
  276. package/source/parsePhoneNumber.test.js +53 -85
  277. package/source/parsePhoneNumberWithError.js +7 -0
  278. package/source/parsePhoneNumberWithError.test.js +112 -0
  279. package/source/parsePhoneNumberWithError_.js +5 -0
  280. package/source/parsePhoneNumber_.js +22 -3
  281. package/source/searchPhoneNumbersInText.js +22 -5
  282. package/source/searchPhoneNumbersInText.test.js +24 -0
  283. package/source/validatePhoneNumberLength.js +3 -3
  284. package/types.d.ts +12 -1
  285. package/build/findNumbers.js +0 -22
  286. package/build/findNumbers.js.map +0 -1
  287. package/build/findNumbers.test.js.map +0 -1
  288. package/build/findNumbers_.js +0 -22
  289. package/build/findNumbers_.js.map +0 -1
  290. package/build/findPhoneNumbers.js.map +0 -1
  291. package/build/findPhoneNumbers.test.js.map +0 -1
  292. package/build/findPhoneNumbers_.js.map +0 -1
  293. package/build/formatNumberForMobileDialing.js.map +0 -1
  294. package/build/formatNumberForMobileDialing.test.js +0 -15
  295. package/build/formatNumberForMobileDialing.test.js.map +0 -1
  296. package/build/format_.js +0 -203
  297. package/build/format_.js.map +0 -1
  298. package/build/getNumberType.js.map +0 -1
  299. package/build/getNumberType.test.js.map +0 -1
  300. package/build/isPossibleNumber.js.map +0 -1
  301. package/build/isPossibleNumber.test.js.map +0 -1
  302. package/build/isPossibleNumber_.js.map +0 -1
  303. package/build/isValidNumberForRegion.js +0 -42
  304. package/build/isValidNumberForRegion.js.map +0 -1
  305. package/build/isValidNumberForRegion.test.js.map +0 -1
  306. package/build/isValidNumberForRegion_.js.map +0 -1
  307. package/build/parsePhoneNumberFromString.js +0 -22
  308. package/build/parsePhoneNumberFromString.js.map +0 -1
  309. package/build/parsePhoneNumberFromString.test.js +0 -92
  310. package/build/parsePhoneNumberFromString.test.js.map +0 -1
  311. package/build/parsePhoneNumberFromString_.js.map +0 -1
  312. package/build/parse_.js +0 -371
  313. package/build/parse_.js.map +0 -1
  314. package/build/searchNumbers.js.map +0 -1
  315. package/build/searchNumbers.test.js.map +0 -1
  316. package/build/validate.js.map +0 -1
  317. package/build/validate.test.js.map +0 -1
  318. package/build/validate_.js.map +0 -1
  319. package/es6/findNumbers.js +0 -11
  320. package/es6/findNumbers.js.map +0 -1
  321. package/es6/findNumbers.test.js.map +0 -1
  322. package/es6/findNumbers_.js +0 -12
  323. package/es6/findNumbers_.js.map +0 -1
  324. package/es6/findPhoneNumbers.js.map +0 -1
  325. package/es6/findPhoneNumbers.test.js.map +0 -1
  326. package/es6/findPhoneNumbers_.js.map +0 -1
  327. package/es6/formatNumberForMobileDialing.js.map +0 -1
  328. package/es6/formatNumberForMobileDialing.test.js +0 -14
  329. package/es6/formatNumberForMobileDialing.test.js.map +0 -1
  330. package/es6/format_.js +0 -187
  331. package/es6/format_.js.map +0 -1
  332. package/es6/getNumberType.js.map +0 -1
  333. package/es6/getNumberType.test.js.map +0 -1
  334. package/es6/isPossibleNumber.js.map +0 -1
  335. package/es6/isPossibleNumber.test.js.map +0 -1
  336. package/es6/isPossibleNumber_.js.map +0 -1
  337. package/es6/isValidNumberForRegion.js +0 -30
  338. package/es6/isValidNumberForRegion.js.map +0 -1
  339. package/es6/isValidNumberForRegion.test.js.map +0 -1
  340. package/es6/isValidNumberForRegion_.js.map +0 -1
  341. package/es6/parsePhoneNumberFromString.js +0 -11
  342. package/es6/parsePhoneNumberFromString.js.map +0 -1
  343. package/es6/parsePhoneNumberFromString.test.js +0 -87
  344. package/es6/parsePhoneNumberFromString.test.js.map +0 -1
  345. package/es6/parsePhoneNumberFromString_.js.map +0 -1
  346. package/es6/parse_.js +0 -339
  347. package/es6/parse_.js.map +0 -1
  348. package/es6/searchNumbers.js.map +0 -1
  349. package/es6/searchNumbers.test.js.map +0 -1
  350. package/es6/validate.js.map +0 -1
  351. package/es6/validate.test.js.map +0 -1
  352. package/es6/validate_.js.map +0 -1
  353. package/max/exports/parsePhoneNumberFromString.js +0 -6
  354. package/min/exports/parsePhoneNumberFromString.js +0 -6
  355. package/mobile/exports/parsePhoneNumberFromString.js +0 -6
  356. package/source/findNumbers.js +0 -7
  357. package/source/findNumbers_.js +0 -10
  358. package/source/formatNumberForMobileDialing.test.js +0 -16
  359. package/source/format_.js +0 -184
  360. package/source/isValidNumberForRegion.js +0 -24
  361. package/source/parsePhoneNumberFromString.js +0 -7
  362. package/source/parsePhoneNumberFromString.test.js +0 -80
  363. package/source/parsePhoneNumberFromString_.js +0 -24
  364. package/source/parse_.js +0 -344
package/README.md CHANGED
@@ -152,6 +152,7 @@ const phoneNumber = parsePhoneNumber(' 8 (800) 555-35-35 ', 'RU')
152
152
  if (phoneNumber) {
153
153
  phoneNumber.country === 'RU'
154
154
  phoneNumber.number === '+78005553535'
155
+ phoneNumber.isPossible() === true
155
156
  phoneNumber.isValid() === true
156
157
  // Note: `.getType()` requires `/max` metadata: see below for an explanation.
157
158
  phoneNumber.getType() === 'TOLL_FREE'
@@ -184,7 +185,7 @@ isPossiblePhoneNumber('8 (800) 555-35-35', 'RU') === true
184
185
  isValidPhoneNumber('8 (800) 555-35-35', 'RU') === true
185
186
 
186
187
  validatePhoneNumberLength('8 (800) 555', 'RU') === 'TOO_SHORT'
187
- validatePhoneNumberLength('8 (800) 555-35-35', 'RU') === undefined
188
+ validatePhoneNumberLength('8 (800) 555-35-35', 'RU') === undefined // Length is valid.
188
189
  ```
189
190
 
190
191
  `isPossiblePhoneNumber()` only validates phone number length, while `isValidPhoneNumber()` validates both phone number length and the actual phone number digits.
@@ -342,7 +343,7 @@ Such phone numbering plans are called "non-geographic", and their phone numbers
342
343
 
343
344
  ## API
344
345
 
345
- ### parsePhoneNumber(string, [options or defaultCountry]): PhoneNumber
346
+ ### parsePhoneNumber(string, defaultCountry?: string | options?: object): PhoneNumber
346
347
 
347
348
  Parses a phone number from `string`.
348
349
 
@@ -362,11 +363,11 @@ Returns an instance of [`PhoneNumber`](#phonenumber) class, or `undefined` if no
362
363
 
363
364
  Available `options`:
364
365
 
365
- * `defaultCountry: string` — Default [country](#country-code) for parsing national numbers. Instead of passing `options.defaultCountry` one could pass `defaultCountry` argument directly.
366
+ * `defaultCountry: string` — Default [country](#country-code) for parsing numbers written in non-international form (without a `+` sign). Will be ignored when parsing numbers written in international form (with a `+` sign). Instead of passing it as `options.defaultCountry`, one could also pass it as a standalone `defaultCountry` argument (for convenience).
366
367
 
367
- * `defaultCallingCode: string` — Default [calling code](#country-calling-code) for parsing national numbers. Some numbering plans are for ["non-geographic numbering plans"](#non-geographic) and they don't have a country code, so `defaultCountry` can't be specified for them.
368
+ * `defaultCallingCode: string` — Default calling code for parsing numbers written in non-international form (without a `+` sign). Will be ignored when parsing numbers written in international form (with a `+` sign). It could be specified when parsing phone numbers belonging to ["non-geographic numbering plans"](#non-geographic) which by nature don't have a country code, making the `defaultCountry` option unusable.
368
369
 
369
- * `extract: boolean` — Defines the ["strictness"](#strictness) of parsing a phone number.
370
+ * `extract: boolean` — Defines the ["strictness"](#strictness) of parsing a phone number. By default, the `extract` flag is `true` meaning that it will attempt to extract the phone number from an input string like `"My phone number is (213) 373-4253 and my hair is blue"`. This could be thought of as "less strict" parsing. To make it "more strict", one could pass `extract: false` flag, in which case the function will attempt to parse the input string as if the whole string was a phone number. Applied to the example above, it would return `undefined` because the entire string is not a phone number, but for input string `"(213) 373-4253"` it would return a parsed `PhoneNumber`.
370
371
 
371
372
  If a developer wants to know the exact reason why the phone number couldn't be parsed then they can use `parsePhoneNumberWithError()` function which throws the exact error:
372
373
 
@@ -374,7 +375,9 @@ If a developer wants to know the exact reason why the phone number couldn't be p
374
375
  import { parsePhoneNumberWithError, ParseError } from 'libphonenumber-js'
375
376
 
376
377
  try {
377
- const phoneNumber = parsePhoneNumberWithError('(213) 373-42-53 ext. 1234', 'US')
378
+ const phoneNumber = parsePhoneNumberWithError('(213) 373-42-53 ext. 1234', {
379
+ defaultCountry: 'US'
380
+ })
378
381
  } catch (error) {
379
382
  if (error instanceof ParseError) {
380
383
  // Not a phone number, non-existent country, etc.
@@ -415,6 +418,11 @@ parsePhoneNumber('Call: (213) 373-4253', {
415
418
  defaultCountry: 'US',
416
419
  extract: false
417
420
  }) === undefined
421
+
422
+ parsePhoneNumber('(213) 373-4253', {
423
+ defaultCountry: 'US',
424
+ extract: false
425
+ }) === PhoneNumber
418
426
  ```
419
427
 
420
428
  ### `PhoneNumber`
@@ -539,6 +547,45 @@ Is just an alias for `this.isValid() && this.country === country`.
539
547
  https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion
540
548
  -->
541
549
 
550
+ <!--
551
+ See the comments for `validateLength()` method in `PhoneNumber.js` class for the rationale on why is this method not part of the public API.
552
+
553
+ #### `validateLength(): string?`
554
+
555
+ Checks if the phone number length is valid. If it is, then nothing is returned. Otherwise, a rejection reason is returned.
556
+
557
+ ```js
558
+ parsePhoneNumber('444 1 44', 'TR').validateLength() === 'TOO_SHORT'
559
+ parsePhoneNumber('444 1 444', 'TR').validateLength() === undefined // Length is valid.
560
+ parsePhoneNumber('444 1 4444', 'TR').validateLength() === 'INVALID_LENGTH'
561
+ parsePhoneNumber('444 1 44444', 'TR').validateLength() === 'INVALID_LENGTH'
562
+ parsePhoneNumber('444 1 444444', 'TR').validateLength() === undefined // Length is valid.
563
+ parsePhoneNumber('444 1 4444444444', 'TR').validateLength() === 'TOO_LONG'
564
+ ```
565
+
566
+ <details>
567
+ <summary>Possible rejection reasons</summary>
568
+
569
+ * `NOT_A_NUMBER` — When the supplied string is not a phone number. For example, when there are no digits: `"abcde"`, `"+"`.
570
+
571
+ * `INVALID_COUNTRY`
572
+
573
+ * When `defaultCountry` doesn't exist (or isn't supported by this library yet): `parsePhoneNumber('(111) 222-3333', 'XX')`.
574
+ * When parsing a non-international number without a `defaultCountry`: `parsePhoneNumber('(111) 222-3333')`.
575
+ * When an international number's country calling code doesn't exist: `parsePhoneNumber('+9991112223333')`.
576
+
577
+ * `TOO_SHORT` — When the number is too short. For example, just 1 or 2 digits: `"1"`, `"+12"`.
578
+
579
+ * `TOO_LONG` — When the national (significant) number is too long (17 digits max) or when the string being parsed is too long (250 characters max).
580
+
581
+ * `INVALID_LENGTH` — When the national (significant) number is neither too short, nor too long, but somewhere in between and its length is still invalid.
582
+ </details>
583
+
584
+ ######
585
+
586
+ `validateLength()` is just a more detailed version of `isPossible()` — if the phone number length is invalid, it returns the actual reason: `TOO_SHORT`, `TOO_LONG`, etc.
587
+ -->
588
+
542
589
  #### `getPossibleCountries(): string[]`
543
590
 
544
591
  Returns a list of countries this phone number could possibly belong to.
@@ -606,7 +653,7 @@ Returns `true` if the number belongs to a ["non-geographic numbering plan"](#non
606
653
 
607
654
  Compares two `PhoneNumber`s: returns `true` if they're equal, `false` otherwise.
608
655
 
609
- ### `isPossiblePhoneNumber(input: string): boolean`
656
+ ### `isPossiblePhoneNumber(input: string, defaultCountry?: string | options?: object): boolean`
610
657
 
611
658
  Checks if `input` can be parsed as a "possible" phone number. A phone number is "possible" when it has valid length. The actual phone number digits aren't validated.
612
659
 
@@ -615,11 +662,13 @@ isPossiblePhoneNumber('8 (888) 888-88-88', 'RU') === true
615
662
  isPossiblePhoneNumber('+12223333333') === true
616
663
  ```
617
664
 
665
+ For the description of the `defaultCountry?: string | options?: object` argument, see [`parsePhoneNumber()`](#parsephonenumberstring-defaultcountry-string-options-object-phonenumber) function description.
666
+
618
667
  This function is just a shortcut for a two-step process of ["strictly"](#strictness) parsing a phone number and then calling `.isPossible()`.
619
668
 
620
- ### `isValidPhoneNumber(input: string): boolean`
669
+ ### `isValidPhoneNumber(input: string, defaultCountry?: string | options?: object): boolean`
621
670
 
622
- Checks if `input` can be parsed as a "valid" phone number. A phone number is "valid" when it has valid length, and the actual phone number digits match the regular expressions for that country.
671
+ Checks if `input` can be parsed as a "valid" phone number. A phone number is "valid" when it has valid length, and the actual phone number digits match the regular expressions for its country.
623
672
 
624
673
  ```js
625
674
  isValidPhoneNumber('8 (888) 888-88-88', 'RU') === false
@@ -628,11 +677,47 @@ isValidPhoneNumber('+12223333333') === false
628
677
  isValidPhoneNumber('+12133734253') === true
629
678
  ```
630
679
 
680
+ For the description of the `defaultCountry?: string | options?: object` argument, see [`parsePhoneNumber()`](#parsephonenumberstring-defaultcountry-string-options-object-phonenumber) function description.
681
+
631
682
  This function is just a shortcut for a two-step process of ["strictly"](#strictness) parsing a phone number and then calling `.isValid()`.
632
683
 
633
684
  See ["Using phone number validation feature"](#using-phone-number-validation-feature) for choosing between `isPossible()` and `isValid()`.
634
685
 
635
- ### `validatePhoneNumberLength(input: string): string?`
686
+ ### `isValidPhoneNumberForCountry(input: string, country: string): boolean`
687
+
688
+ Same as `isValidPhoneNumber()` but with the "default country" argument being an "exact country" instead.
689
+
690
+ This function is not currently exported from this library. The reason is that its result would be too vague when `false` is returned — it could mean any of:
691
+
692
+ * The input is not a valid phone number.
693
+ * The input is a valid phone number but it belongs to another country.
694
+ * The input is a phone number that belongs to the correct country but is not valid.
695
+
696
+ At least the second case should be handled separately from a "User Experience" point of view: if the user has input a valid phone number but for another country, they should be notified that "the country is incorrect" rather than that "the phone number is incorrect", otherwise it would be bad UX design.
697
+
698
+ But for those who'd still like to have such function, here's a possible implementation for it:
699
+
700
+ ```js
701
+ export default function isValidPhoneNumberForCountry(phoneNumberString, country) {
702
+ const phoneNumber = parsePhoneNumber(phoneNumberString, {
703
+ defaultCountry: country,
704
+ // Demand that the entire input string must be a phone number.
705
+ // Otherwise, it would "extract" a phone number from an input string.
706
+ extract: false
707
+ })
708
+ if (!phoneNumber) {
709
+ return false
710
+ }
711
+ if (phoneNumber.country !== country) {
712
+ return false
713
+ }
714
+ return phoneNumber.isValid()
715
+ }
716
+ ```
717
+
718
+ The same approach could be used to implement an `isPossiblePhoneNumberForCountry()` function.
719
+
720
+ ### `validatePhoneNumberLength(input: string, defaultCountry?: string | options?: object): string?`
636
721
 
637
722
  Checks if `input` phone number length is valid. If it is, then nothing is returned. Otherwise, a rejection reason is returned.
638
723
 
@@ -660,24 +745,26 @@ Checks if `input` phone number length is valid. If it is, then nothing is return
660
745
  validatePhoneNumberLength('abcde') === 'NOT_A_NUMBER'
661
746
  validatePhoneNumberLength('444 1 44') === 'INVALID_COUNTRY'
662
747
  validatePhoneNumberLength('444 1 44', 'TR') === 'TOO_SHORT'
663
- validatePhoneNumberLength('444 1 444', 'TR') === undefined
748
+ validatePhoneNumberLength('444 1 444', 'TR') === undefined // Length is valid.
664
749
  validatePhoneNumberLength('444 1 4444', 'TR') === 'INVALID_LENGTH'
665
750
  validatePhoneNumberLength('444 1 44444', 'TR') === 'INVALID_LENGTH'
666
- validatePhoneNumberLength('444 1 444444', 'TR') === undefined
751
+ validatePhoneNumberLength('444 1 444444', 'TR') === undefined // Length is valid.
667
752
  validatePhoneNumberLength('444 1 4444444444', 'TR') === 'TOO_LONG'
668
753
  ```
669
754
 
755
+ For the description of the `defaultCountry?: string | options?: object` argument, see [`parsePhoneNumber()`](#parsephonenumberstring-defaultcountry-string-options-object-phonenumber) function description.
756
+
670
757
  This function is just a more detailed version of `isPossiblePhoneNumber()` for those who've [asked](https://github.com/catamphetamine/libphonenumber-js/issues/406) for a more specific rejection reason.
671
758
 
672
- ### `class` AsYouType([options or defaultCountry])
759
+ <!-- This function is just a shortcut for a two-step process of ["strictly"](#strictness) parsing a phone number and then calling `.validateLength()`. -->
673
760
 
674
- Creates a formatter for a partially entered phone number.
761
+ The phone number is parsed ["strictly"](#strictness) from the input string.
675
762
 
676
- Available `options`:
763
+ ### `class` AsYouType(defaultCountry?: string | options?: object)
677
764
 
678
- * `defaultCountry` — Default [country](#country-code) for parsing national numbers. Instead of passing `options.defaultCountry` one could pass `defaultCountry` argument directly.
765
+ Creates a formatter for a partially entered phone number.
679
766
 
680
- * `defaultCallingCode` — Default calling code for parsing national numbers. Some numbering plans are for ["non-geographic numbering plans"](#non-geographic) and they don't have a country code, so `defaultCountry` can't be specified for them.
767
+ For the description of the `defaultCountry?: string | options?: object` argument, see [`parsePhoneNumber()`](#parsephonenumberstring-defaultcountry-string-options-object-phonenumber) function description.
681
768
 
682
769
  The formatter instance has the following methods:
683
770
 
@@ -790,15 +877,11 @@ asYouType.getNationalNumber() === '2133734253'
790
877
 
791
878
  Google's "As You Type" formatter does not support entering phone number extensions. If your project requires phone number extensions input then use a separate input field for that.
792
879
 
793
- ### findPhoneNumbersInText(text: string, [defaultCountry: string?], [options]): object[]
880
+ ### findPhoneNumbersInText(text: string, defaultCountry?: string | options?: object): object[]
794
881
 
795
882
  Searches for phone numbers in `text`.
796
883
 
797
- Available `options`:
798
-
799
- * `defaultCountry` — Default [country](#country-code) for parsing national numbers. Instead of passing `options.defaultCountry` one could pass `defaultCountry` argument directly.
800
-
801
- * `defaultCallingCode` — Default calling code for parsing national numbers. Some numbering plans are for ["non-geographic numbering plans"](#non-geographic) and they don't have a country code, so `defaultCountry` can't be specified for them.
884
+ For the description of the `defaultCountry?: string | options?: object` argument, see [`parsePhoneNumber()`](#parsephonenumberstring-defaultcountry-string-options-object-phonenumber) function description.
802
885
 
803
886
  ```js
804
887
  import { findPhoneNumbersInText } from 'libphonenumber-js'
@@ -1301,7 +1384,7 @@ The precise regular expressions aren't included in the default metadata because
1301
1384
  <details>
1302
1385
  <summary><code>isValidNumberForRegion()</code></summary>
1303
1386
 
1304
- The optional `defaultCountry` argument is the _default_ country, i.e. it does not restrict to just that country, e.g. in those cases where several countries share the same phone numbering rules (NANPA, Britain, etc). For example, even though the number `07624 369230` belongs to the Isle of Man ("IM" country code) calling `isValidNumber('07624369230', 'GB')` still returns `true` because the country is not restricted to `GB`, it's just that `GB` is the default one for the phone numbering rules. For restricting the country see `isValidNumberForRegion()` though restricting a country [might not be a good idea](https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion).
1387
+ The optional `defaultCountry` argument is the _default_ country, i.e. it does not restrict to just that country, e.g. in those cases where several countries share the same phone numbering rules (NANPA, Britain, etc). For example, even though the number `07624 369230` belongs to the Isle of Man ("IM" country code) calling `isValidNumber('07624369230', 'GB')` still returns `true` because the country is not restricted to `GB`, it's just that `GB` is the default one for the phone numbering rules. For restricting the country, see `isValidNumberForRegion()`, though restricting a country [might not be a good idea](https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion).
1305
1388
 
1306
1389
  ```js
1307
1390
  // Even though '07624 369230' number belongs to the Isle of Man ("IM")
@@ -5,19 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
 
8
- var _metadata2 = _interopRequireDefault(require("./metadata.js"));
8
+ var _metadata = _interopRequireDefault(require("./metadata.js"));
9
9
 
10
- var _isPossibleNumber_ = _interopRequireDefault(require("./isPossibleNumber_.js"));
10
+ var _isPossible = _interopRequireDefault(require("./isPossible.js"));
11
11
 
12
- var _validate_ = _interopRequireDefault(require("./validate_.js"));
13
-
14
- var _isValidNumberForRegion_ = _interopRequireDefault(require("./isValidNumberForRegion_.js"));
12
+ var _isValid = _interopRequireDefault(require("./isValid.js"));
15
13
 
16
14
  var _getNumberType = _interopRequireDefault(require("./helpers/getNumberType.js"));
17
15
 
18
16
  var _getPossibleCountriesForNumber = _interopRequireDefault(require("./helpers/getPossibleCountriesForNumber.js"));
19
17
 
20
- var _format_ = _interopRequireDefault(require("./format_.js"));
18
+ var _format2 = _interopRequireDefault(require("./format.js"));
21
19
 
22
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
21
 
@@ -36,10 +34,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
36
34
  var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
37
35
 
38
36
  var PhoneNumber = /*#__PURE__*/function () {
39
- function PhoneNumber(countryCallingCode, nationalNumber, metadata) {
37
+ function PhoneNumber(countryOrCountryCallingCode, nationalNumber, metadata) {
40
38
  _classCallCheck(this, PhoneNumber);
41
39
 
42
- if (!countryCallingCode) {
40
+ if (!countryOrCountryCallingCode) {
43
41
  throw new TypeError('`country` or `countryCallingCode` not passed');
44
42
  }
45
43
 
@@ -51,25 +49,11 @@ var PhoneNumber = /*#__PURE__*/function () {
51
49
  throw new TypeError('`metadata` not passed');
52
50
  }
53
51
 
54
- var _metadata = new _metadata2["default"](metadata); // If country code is passed then derive `countryCallingCode` from it.
55
- // Also store the country code as `.country`.
56
-
57
-
58
- if (isCountryCode(countryCallingCode)) {
59
- this.country = countryCallingCode;
60
-
61
- _metadata.country(countryCallingCode);
62
-
63
- countryCallingCode = _metadata.countryCallingCode();
64
- } else {
65
- /* istanbul ignore if */
66
- if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
67
- if (_metadata.isNonGeographicCallingCode(countryCallingCode)) {
68
- this.country = '001';
69
- }
70
- }
71
- }
52
+ var _getCountryAndCountry = getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadata),
53
+ country = _getCountryAndCountry.country,
54
+ countryCallingCode = _getCountryAndCountry.countryCallingCode;
72
55
 
56
+ this.country = country;
73
57
  this.countryCallingCode = countryCallingCode;
74
58
  this.nationalNumber = nationalNumber;
75
59
  this.number = '+' + this.countryCallingCode + this.nationalNumber;
@@ -93,31 +77,40 @@ var PhoneNumber = /*#__PURE__*/function () {
93
77
  }, {
94
78
  key: "isPossible",
95
79
  value: function isPossible() {
96
- return (0, _isPossibleNumber_["default"])(this, {
80
+ return (0, _isPossible["default"])(this, {
97
81
  v2: true
98
82
  }, this.metadata);
99
83
  }
100
84
  }, {
101
85
  key: "isValid",
102
86
  value: function isValid() {
103
- return (0, _validate_["default"])(this, {
87
+ return (0, _isValid["default"])(this, {
104
88
  v2: true
105
89
  }, this.metadata);
106
90
  }
107
91
  }, {
108
92
  key: "isNonGeographic",
109
93
  value: function isNonGeographic() {
110
- var metadata = new _metadata2["default"](this.metadata);
94
+ var metadata = new _metadata["default"](this.metadata);
111
95
  return metadata.isNonGeographicCallingCode(this.countryCallingCode);
112
96
  }
113
97
  }, {
114
98
  key: "isEqual",
115
99
  value: function isEqual(phoneNumber) {
116
100
  return this.number === phoneNumber.number && this.ext === phoneNumber.ext;
117
- } // // Is just an alias for `this.isValid() && this.country === country`.
118
- // // https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion
119
- // isValidForRegion(country) {
120
- // return isValidNumberForRegion(this, country, { v2: true }, this.metadata)
101
+ } // This function was originally meant to be an equivalent for `validatePhoneNumberLength()`,
102
+ // but later it was found out that it doesn't include the possible `TOO_SHORT` result
103
+ // returned from `parsePhoneNumberWithError()` in the original `validatePhoneNumberLength()`,
104
+ // so eventually I simply commented out this method from the `PhoneNumber` class
105
+ // and just left the `validatePhoneNumberLength()` function, even though that one would require
106
+ // and additional step to also validate the actual country / calling code of the phone number.
107
+ // validateLength() {
108
+ // const metadata = new Metadata(this.metadata)
109
+ // metadata.selectNumberingPlan(this.countryCallingCode)
110
+ // const result = checkNumberLength(this.nationalNumber, metadata)
111
+ // if (result !== 'IS_POSSIBLE') {
112
+ // return result
113
+ // }
121
114
  // }
122
115
 
123
116
  }, {
@@ -130,7 +123,7 @@ var PhoneNumber = /*#__PURE__*/function () {
130
123
  }, {
131
124
  key: "format",
132
125
  value: function format(_format, options) {
133
- return (0, _format_["default"])(this, _format, options ? _objectSpread(_objectSpread({}, options), {}, {
126
+ return (0, _format2["default"])(this, _format, options ? _objectSpread(_objectSpread({}, options), {}, {
134
127
  v2: true
135
128
  }) : {
136
129
  v2: true
@@ -161,4 +154,31 @@ exports["default"] = PhoneNumber;
161
154
  var isCountryCode = function isCountryCode(value) {
162
155
  return /^[A-Z]{2}$/.test(value);
163
156
  };
157
+
158
+ function getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadataJson) {
159
+ var country;
160
+ var countryCallingCode;
161
+ var metadata = new _metadata["default"](metadataJson); // If country code is passed then derive `countryCallingCode` from it.
162
+ // Also store the country code as `.country`.
163
+
164
+ if (isCountryCode(countryOrCountryCallingCode)) {
165
+ country = countryOrCountryCallingCode;
166
+ metadata.selectNumberingPlan(country);
167
+ countryCallingCode = metadata.countryCallingCode();
168
+ } else {
169
+ countryCallingCode = countryOrCountryCallingCode;
170
+ /* istanbul ignore if */
171
+
172
+ if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
173
+ if (metadata.isNonGeographicCallingCode(countryCallingCode)) {
174
+ country = '001';
175
+ }
176
+ }
177
+ }
178
+
179
+ return {
180
+ country: country,
181
+ countryCallingCode: countryCallingCode
182
+ };
183
+ }
164
184
  //# sourceMappingURL=PhoneNumber.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneNumber.js","names":["USE_NON_GEOGRAPHIC_COUNTRY_CODE","PhoneNumber","countryCallingCode","nationalNumber","metadata","TypeError","_metadata","Metadata","isCountryCode","country","isNonGeographicCallingCode","number","ext","getPossibleCountriesForNumber","isPossibleNumber","v2","isValidNumber","phoneNumber","getNumberType","format","options","formatNumber","value","test"],"sources":["../source/PhoneNumber.js"],"sourcesContent":["import Metadata from './metadata.js'\r\nimport isPossibleNumber from './isPossibleNumber_.js'\r\nimport isValidNumber from './validate_.js'\r\nimport isValidNumberForRegion from './isValidNumberForRegion_.js'\r\nimport getNumberType from './helpers/getNumberType.js'\r\nimport getPossibleCountriesForNumber from './helpers/getPossibleCountriesForNumber.js'\r\nimport formatNumber from './format_.js'\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\nexport default class PhoneNumber {\r\n\tconstructor(countryCallingCode, nationalNumber, metadata) {\r\n\t\tif (!countryCallingCode) {\r\n\t\t\tthrow new TypeError('`country` or `countryCallingCode` not passed')\r\n\t\t}\r\n\t\tif (!nationalNumber) {\r\n\t\t\tthrow new TypeError('`nationalNumber` not passed')\r\n\t\t}\r\n\t\tif (!metadata) {\r\n\t\t\tthrow new TypeError('`metadata` not passed')\r\n\t\t}\r\n\t\tconst _metadata = new Metadata(metadata)\r\n\t\t// If country code is passed then derive `countryCallingCode` from it.\r\n\t\t// Also store the country code as `.country`.\r\n\t\tif (isCountryCode(countryCallingCode)) {\r\n\t\t\tthis.country = countryCallingCode\r\n\t\t\t_metadata.country(countryCallingCode)\r\n\t\t\tcountryCallingCode = _metadata.countryCallingCode()\r\n\t\t} else {\r\n\t\t\t/* istanbul ignore if */\r\n\t\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\t\tif (_metadata.isNonGeographicCallingCode(countryCallingCode)) {\r\n\t\t\t\t\tthis.country = '001'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.countryCallingCode = countryCallingCode\r\n\t\tthis.nationalNumber = nationalNumber\r\n\t\tthis.number = '+' + this.countryCallingCode + this.nationalNumber\r\n\t\tthis.metadata = metadata\r\n\t}\r\n\r\n\tsetExt(ext) {\r\n\t\tthis.ext = ext\r\n\t}\r\n\r\n\tgetPossibleCountries() {\r\n\t\tif (this.country) {\r\n\t\t\treturn [this.country]\r\n\t\t}\r\n\t\treturn getPossibleCountriesForNumber(\r\n\t\t\tthis.countryCallingCode,\r\n\t\t\tthis.nationalNumber,\r\n\t\t\tthis.metadata\r\n\t\t)\r\n\t}\r\n\r\n\tisPossible() {\r\n\t\treturn isPossibleNumber(this, { v2: true }, this.metadata)\r\n\t}\r\n\r\n\tisValid() {\r\n\t\treturn isValidNumber(this, { v2: true }, this.metadata)\r\n\t}\r\n\r\n\tisNonGeographic() {\r\n\t\tconst metadata = new Metadata(this.metadata)\r\n\t\treturn metadata.isNonGeographicCallingCode(this.countryCallingCode)\r\n\t}\r\n\r\n\tisEqual(phoneNumber) {\r\n\t\treturn this.number === phoneNumber.number && this.ext === phoneNumber.ext\r\n\t}\r\n\r\n\t// // Is just an alias for `this.isValid() && this.country === country`.\r\n\t// // https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion\r\n\t// isValidForRegion(country) {\r\n\t// \treturn isValidNumberForRegion(this, country, { v2: true }, this.metadata)\r\n\t// }\r\n\r\n\tgetType() {\r\n\t\treturn getNumberType(this, { v2: true }, this.metadata)\r\n\t}\r\n\r\n\tformat(format, options) {\r\n\t\treturn formatNumber(\r\n\t\t\tthis,\r\n\t\t\tformat,\r\n\t\t\toptions ? { ...options, v2: true } : { v2: true },\r\n\t\t\tthis.metadata\r\n\t\t)\r\n\t}\r\n\r\n\tformatNational(options) {\r\n\t\treturn this.format('NATIONAL', options)\r\n\t}\r\n\r\n\tformatInternational(options) {\r\n\t\treturn this.format('INTERNATIONAL', options)\r\n\t}\r\n\r\n\tgetURI(options) {\r\n\t\treturn this.format('RFC3966', options)\r\n\t}\r\n}\r\n\r\nconst isCountryCode = (value) => /^[A-Z]{2}$/.test(value)"],"mappings":";;;;;;;AAAA;;AACA;;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,SAAhBA,aAAgB,CAACc,KAAD;EAAA,OAAW,aAAaC,IAAb,CAAkBD,KAAlB,CAAX;AAAA,CAAtB"}
1
+ {"version":3,"file":"PhoneNumber.js","names":["USE_NON_GEOGRAPHIC_COUNTRY_CODE","PhoneNumber","countryOrCountryCallingCode","nationalNumber","metadata","TypeError","getCountryAndCountryCallingCode","country","countryCallingCode","number","ext","getPossibleCountriesForNumber","isPossibleNumber","v2","isValidNumber","Metadata","isNonGeographicCallingCode","phoneNumber","getNumberType","format","options","formatNumber","isCountryCode","value","test","metadataJson","selectNumberingPlan"],"sources":["../source/PhoneNumber.js"],"sourcesContent":["import Metadata from './metadata.js'\r\nimport isPossibleNumber from './isPossible.js'\r\nimport isValidNumber from './isValid.js'\r\n// import checkNumberLength from './helpers/checkNumberLength.js'\r\nimport getNumberType from './helpers/getNumberType.js'\r\nimport getPossibleCountriesForNumber from './helpers/getPossibleCountriesForNumber.js'\r\nimport formatNumber from './format.js'\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\nexport default class PhoneNumber {\r\n\tconstructor(countryOrCountryCallingCode, nationalNumber, metadata) {\r\n\t\tif (!countryOrCountryCallingCode) {\r\n\t\t\tthrow new TypeError('`country` or `countryCallingCode` not passed')\r\n\t\t}\r\n\t\tif (!nationalNumber) {\r\n\t\t\tthrow new TypeError('`nationalNumber` not passed')\r\n\t\t}\r\n\t\tif (!metadata) {\r\n\t\t\tthrow new TypeError('`metadata` not passed')\r\n\t\t}\r\n\t\tconst { country, countryCallingCode } = getCountryAndCountryCallingCode(\r\n\t\t\tcountryOrCountryCallingCode,\r\n\t\t\tmetadata\r\n\t\t)\r\n\t\tthis.country = country\r\n\t\tthis.countryCallingCode = countryCallingCode\r\n\t\tthis.nationalNumber = nationalNumber\r\n\t\tthis.number = '+' + this.countryCallingCode + this.nationalNumber\r\n\t\tthis.metadata = metadata\r\n\t}\r\n\r\n\tsetExt(ext) {\r\n\t\tthis.ext = ext\r\n\t}\r\n\r\n\tgetPossibleCountries() {\r\n\t\tif (this.country) {\r\n\t\t\treturn [this.country]\r\n\t\t}\r\n\t\treturn getPossibleCountriesForNumber(\r\n\t\t\tthis.countryCallingCode,\r\n\t\t\tthis.nationalNumber,\r\n\t\t\tthis.metadata\r\n\t\t)\r\n\t}\r\n\r\n\tisPossible() {\r\n\t\treturn isPossibleNumber(this, { v2: true }, this.metadata)\r\n\t}\r\n\r\n\tisValid() {\r\n\t\treturn isValidNumber(this, { v2: true }, this.metadata)\r\n\t}\r\n\r\n\tisNonGeographic() {\r\n\t\tconst metadata = new Metadata(this.metadata)\r\n\t\treturn metadata.isNonGeographicCallingCode(this.countryCallingCode)\r\n\t}\r\n\r\n\tisEqual(phoneNumber) {\r\n\t\treturn this.number === phoneNumber.number && this.ext === phoneNumber.ext\r\n\t}\r\n\r\n\t// This function was originally meant to be an equivalent for `validatePhoneNumberLength()`,\r\n\t// but later it was found out that it doesn't include the possible `TOO_SHORT` result\r\n\t// returned from `parsePhoneNumberWithError()` in the original `validatePhoneNumberLength()`,\r\n\t// so eventually I simply commented out this method from the `PhoneNumber` class\r\n\t// and just left the `validatePhoneNumberLength()` function, even though that one would require\r\n\t// and additional step to also validate the actual country / calling code of the phone number.\r\n\t// validateLength() {\r\n\t// \tconst metadata = new Metadata(this.metadata)\r\n\t// \tmetadata.selectNumberingPlan(this.countryCallingCode)\r\n\t// \tconst result = checkNumberLength(this.nationalNumber, metadata)\r\n\t// \tif (result !== 'IS_POSSIBLE') {\r\n\t// \t\treturn result\r\n\t// \t}\r\n\t// }\r\n\r\n\tgetType() {\r\n\t\treturn getNumberType(this, { v2: true }, this.metadata)\r\n\t}\r\n\r\n\tformat(format, options) {\r\n\t\treturn formatNumber(\r\n\t\t\tthis,\r\n\t\t\tformat,\r\n\t\t\toptions ? { ...options, v2: true } : { v2: true },\r\n\t\t\tthis.metadata\r\n\t\t)\r\n\t}\r\n\r\n\tformatNational(options) {\r\n\t\treturn this.format('NATIONAL', options)\r\n\t}\r\n\r\n\tformatInternational(options) {\r\n\t\treturn this.format('INTERNATIONAL', options)\r\n\t}\r\n\r\n\tgetURI(options) {\r\n\t\treturn this.format('RFC3966', options)\r\n\t}\r\n}\r\n\r\nconst isCountryCode = (value) => /^[A-Z]{2}$/.test(value)\r\n\r\nfunction getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadataJson) {\r\n\tlet country\r\n\tlet countryCallingCode\r\n\r\n\tconst metadata = new Metadata(metadataJson)\r\n\t// If country code is passed then derive `countryCallingCode` from it.\r\n\t// Also store the country code as `.country`.\r\n\tif (isCountryCode(countryOrCountryCallingCode)) {\r\n\t\tcountry = countryOrCountryCallingCode\r\n\t\tmetadata.selectNumberingPlan(country)\r\n\t\tcountryCallingCode = metadata.countryCallingCode()\r\n\t} else {\r\n\t\tcountryCallingCode = countryOrCountryCallingCode\r\n\t\t/* istanbul ignore if */\r\n\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\tif (metadata.isNonGeographicCallingCode(countryCallingCode)) {\r\n\t\t\t\tcountry = '001'\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn {\r\n\t\tcountry,\r\n\t\tcountryCallingCode\r\n\t}\r\n}"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;;;;;;;AAEA,IAAMA,+BAA+B,GAAG,KAAxC;;IAEqBC,W;EACpB,qBAAYC,2BAAZ,EAAyCC,cAAzC,EAAyDC,QAAzD,EAAmE;IAAA;;IAClE,IAAI,CAACF,2BAAL,EAAkC;MACjC,MAAM,IAAIG,SAAJ,CAAc,8CAAd,CAAN;IACA;;IACD,IAAI,CAACF,cAAL,EAAqB;MACpB,MAAM,IAAIE,SAAJ,CAAc,6BAAd,CAAN;IACA;;IACD,IAAI,CAACD,QAAL,EAAe;MACd,MAAM,IAAIC,SAAJ,CAAc,uBAAd,CAAN;IACA;;IACD,4BAAwCC,+BAA+B,CACtEJ,2BADs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IACNA,OAAO,EAAPA,OADM;IAENC,kBAAkB,EAAlBA;EAFM,CAAP;AAIA"}
@@ -91,6 +91,12 @@ describe('PhoneNumber', function () {
91
91
  var phoneNumber = new _PhoneNumber["default"]('777', '123', _metadataMin["default"]);
92
92
  expect(phoneNumber.country).to.be.undefined;
93
93
  phoneNumber.getPossibleCountries().should.deep.equal([]);
94
- });
94
+ }); // it('should validate phone number length', () => {
95
+ // const phoneNumber = new PhoneNumber('RU', '800', metadata)
96
+ // expect(phoneNumber.validateLength()).to.equal('TOO_SHORT')
97
+ //
98
+ // const phoneNumberValid = new PhoneNumber('RU', '8005553535', metadata)
99
+ // expect(phoneNumberValid.validateLength()).to.be.undefined
100
+ // })
95
101
  });
96
102
  //# sourceMappingURL=PhoneNumber.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneNumber.test.js","names":["describe","it","expect","PhoneNumber","to","phoneNumber","metadata","countryCallingCode","should","equal","country","number","ext","format","formatExtension","extension","isEqual","isNonGeographic","setExt","formatNational","be","undefined","getPossibleCountries","deep","indexOf","length"],"sources":["../source/PhoneNumber.test.js"],"sourcesContent":["import metadata from '../metadata.min.json' assert { type: 'json' }\r\nimport PhoneNumber from './PhoneNumber.js'\r\n\r\ndescribe('PhoneNumber', () => {\r\n\tit('should validate constructor arguments', () => {\r\n\t\texpect(() => new PhoneNumber()).to.throw('`countryCallingCode` not passed')\r\n\t\texpect(() => new PhoneNumber('7')).to.throw('`nationalNumber` not passed')\r\n\t\texpect(() => new PhoneNumber('7', '8005553535')).to.throw('`metadata` not passed')\r\n\t})\r\n\r\n\tit('should accept country code argument', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('RU', '8005553535', metadata)\r\n\t\tphoneNumber.countryCallingCode.should.equal('7')\r\n\t\tphoneNumber.country.should.equal('RU')\r\n\t\tphoneNumber.number.should.equal('+78005553535')\r\n\t})\r\n\r\n\tit('should format number with options', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('7', '8005553535', metadata)\r\n\t\tphoneNumber.ext = '123'\r\n\t\tphoneNumber.format('NATIONAL', {\r\n\t\t\tformatExtension: (number, extension) => `${number} доб. ${extension}`\r\n\t\t})\r\n\t\t.should.equal('8 (800) 555-35-35 доб. 123')\r\n\t})\r\n\r\n\tit('should compare phone numbers', () => {\r\n\t\tnew PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('RU', '8005553535', metadata)).should.equal(true)\r\n\t\tnew PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('7', '8005553535', metadata)).should.equal(true)\r\n\t\tnew PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('RU', '8005553536', metadata)).should.equal(false)\r\n\t})\r\n\r\n\tit('should tell if a number is non-geographic', () => {\r\n\t\tnew PhoneNumber('7', '8005553535', metadata).isNonGeographic().should.equal(false)\r\n\t\tnew PhoneNumber('870', '773111632', metadata).isNonGeographic().should.equal(true)\r\n\t})\r\n\r\n\tit('should allow setting extension', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('1', '2133734253', metadata)\r\n\t\tphoneNumber.setExt('1234')\r\n\t\tphoneNumber.ext.should.equal('1234')\r\n\t\tphoneNumber.formatNational().should.equal('(213) 373-4253 ext. 1234')\r\n\t})\r\n\r\n\tit('should return possible countries', () => {\r\n // \"599\": [\r\n // \"CW\", // \"possible_lengths\": [7, 8]\r\n // \"BQ\" // \"possible_lengths\": [7]\r\n // ]\r\n\r\n\t\tlet phoneNumber = new PhoneNumber('599', '123456', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\r\n\t\tphoneNumber = new PhoneNumber('599', '1234567', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal(['CW', 'BQ'])\r\n\r\n\t\tphoneNumber = new PhoneNumber('599', '12345678', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal(['CW'])\r\n\r\n\t\tphoneNumber = new PhoneNumber('599', '123456789', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t})\r\n\r\n\tit('should return possible countries in case of ambiguity', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('1', '2223334444', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().indexOf('US').should.equal(0)\r\n\t\tphoneNumber.getPossibleCountries().length.should.equal(25)\r\n\t})\r\n\r\n\t// it('should return empty possible countries when no national number has been input', () => {\r\n\t// \tconst phoneNumber = new PhoneNumber('1', '', metadata)\r\n\t// \texpect(phoneNumber.country).to.be.undefined\r\n\t// \tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t// })\r\n\r\n\tit('should return empty possible countries when not enough national number digits have been input', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('1', '222', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t})\r\n\r\n\tit('should return possible countries in case of no ambiguity', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('US', '2133734253', metadata)\r\n\t\tphoneNumber.country.should.equal('US')\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal(['US'])\r\n\t})\r\n\r\n\tit('should return empty possible countries in case of an unknown calling code', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('777', '123', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t})\r\n})"],"mappings":";;AAAA;;AACA;;;;AAEAA,QAAQ,CAAC,aAAD,EAAgB,YAAM;EAC7BC,EAAE,CAAC,uCAAD,EAA0C,YAAM;IACjDC,MAAM,CAAC;MAAA,OAAM,IAAIC,uBAAJ,EAAN;IAAA,CAAD,CAAN,CAAgCC,EAAhC,UAAyC,iCAAzC;I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/C,CAAqD,EAArD;EACA,CAJC,CAAF;AAKA,CA9FO,CAAR"}
1
+ {"version":3,"file":"PhoneNumber.test.js","names":["describe","it","expect","PhoneNumber","to","phoneNumber","metadata","countryCallingCode","should","equal","country","number","ext","format","formatExtension","extension","isEqual","isNonGeographic","setExt","formatNational","be","undefined","getPossibleCountries","deep","indexOf","length"],"sources":["../source/PhoneNumber.test.js"],"sourcesContent":["import metadata from '../metadata.min.json' assert { type: 'json' }\r\nimport PhoneNumber from './PhoneNumber.js'\r\n\r\ndescribe('PhoneNumber', () => {\r\n\tit('should validate constructor arguments', () => {\r\n\t\texpect(() => new PhoneNumber()).to.throw('`countryCallingCode` not passed')\r\n\t\texpect(() => new PhoneNumber('7')).to.throw('`nationalNumber` not passed')\r\n\t\texpect(() => new PhoneNumber('7', '8005553535')).to.throw('`metadata` not passed')\r\n\t})\r\n\r\n\tit('should accept country code argument', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('RU', '8005553535', metadata)\r\n\t\tphoneNumber.countryCallingCode.should.equal('7')\r\n\t\tphoneNumber.country.should.equal('RU')\r\n\t\tphoneNumber.number.should.equal('+78005553535')\r\n\t})\r\n\r\n\tit('should format number with options', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('7', '8005553535', metadata)\r\n\t\tphoneNumber.ext = '123'\r\n\t\tphoneNumber.format('NATIONAL', {\r\n\t\t\tformatExtension: (number, extension) => `${number} доб. ${extension}`\r\n\t\t})\r\n\t\t.should.equal('8 (800) 555-35-35 доб. 123')\r\n\t})\r\n\r\n\tit('should compare phone numbers', () => {\r\n\t\tnew PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('RU', '8005553535', metadata)).should.equal(true)\r\n\t\tnew PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('7', '8005553535', metadata)).should.equal(true)\r\n\t\tnew PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('RU', '8005553536', metadata)).should.equal(false)\r\n\t})\r\n\r\n\tit('should tell if a number is non-geographic', () => {\r\n\t\tnew PhoneNumber('7', '8005553535', metadata).isNonGeographic().should.equal(false)\r\n\t\tnew PhoneNumber('870', '773111632', metadata).isNonGeographic().should.equal(true)\r\n\t})\r\n\r\n\tit('should allow setting extension', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('1', '2133734253', metadata)\r\n\t\tphoneNumber.setExt('1234')\r\n\t\tphoneNumber.ext.should.equal('1234')\r\n\t\tphoneNumber.formatNational().should.equal('(213) 373-4253 ext. 1234')\r\n\t})\r\n\r\n\tit('should return possible countries', () => {\r\n // \"599\": [\r\n // \"CW\", // \"possible_lengths\": [7, 8]\r\n // \"BQ\" // \"possible_lengths\": [7]\r\n // ]\r\n\r\n\t\tlet phoneNumber = new PhoneNumber('599', '123456', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\r\n\t\tphoneNumber = new PhoneNumber('599', '1234567', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal(['CW', 'BQ'])\r\n\r\n\t\tphoneNumber = new PhoneNumber('599', '12345678', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal(['CW'])\r\n\r\n\t\tphoneNumber = new PhoneNumber('599', '123456789', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t})\r\n\r\n\tit('should return possible countries in case of ambiguity', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('1', '2223334444', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().indexOf('US').should.equal(0)\r\n\t\tphoneNumber.getPossibleCountries().length.should.equal(25)\r\n\t})\r\n\r\n\t// it('should return empty possible countries when no national number has been input', () => {\r\n\t// \tconst phoneNumber = new PhoneNumber('1', '', metadata)\r\n\t// \texpect(phoneNumber.country).to.be.undefined\r\n\t// \tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t// })\r\n\r\n\tit('should return empty possible countries when not enough national number digits have been input', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('1', '222', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t})\r\n\r\n\tit('should return possible countries in case of no ambiguity', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('US', '2133734253', metadata)\r\n\t\tphoneNumber.country.should.equal('US')\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal(['US'])\r\n\t})\r\n\r\n\tit('should return empty possible countries in case of an unknown calling code', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('777', '123', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t})\r\n\r\n\t// it('should validate phone number length', () => {\r\n\t// \tconst phoneNumber = new PhoneNumber('RU', '800', metadata)\r\n\t// \texpect(phoneNumber.validateLength()).to.equal('TOO_SHORT')\r\n\t//\r\n\t// \tconst phoneNumberValid = new PhoneNumber('RU', '8005553535', metadata)\r\n\t// \texpect(phoneNumberValid.validateLength()).to.be.undefined\r\n\t// })\r\n})"],"mappings":";;AAAA;;AACA;;;;AAEAA,QAAQ,CAAC,aAAD,EAAgB,YAAM;EAC7BC,EAAE,CAAC,uCAAD,EAA0C,YAAM;IACjDC,MAAM,CAAC;MAAA,OAAM,IAAIC,uBAAJ,EAAN;IAAA,CAAD,CAAN,CAAgCC,EAAhC,UAAyC,iCAAzC;IACAF,MAAM,CAAC;MAAA,OAAM,IAAIC,uBAAJ,CAAgB,GAAhB,CAAN;IAAA,CAAD,CAAN,CAAmCC,EAAnC,UAA4C,6BAA5C;IACAF,MAAM,CAAC;MAAA,OAAM,IAAIC,uBAAJ,CAAgB,GAAhB,EAAqB,YAArB,CAAN;IAAA,CAAD,CAAN,C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,CAAuD,EAAvD;EACA,CALC,CAAF,CAhE6B,CAuE7B;EACA;EACA;EACA;EACA;;EAEAR,EAAE,CAAC,+FAAD,EAAkG,YAAM;IACzG,IAAMI,WAAW,GAAG,IAAIF,uBAAJ,CAAgB,GAAhB,EAAqB,KAArB,EAA4BG,uBAA5B,CAApB;IACAJ,MAAM,CAACG,WAAW,CAACK,OAAb,CAAN,CAA4BN,EAA5B,CAA+BgB,EAA/B,CAAkCC,SAAlC;IACAhB,WAAW,CAACiB,oBAAZ,GAAmCd,MAAnC,CAA0Ce,IAA1C,CAA+Cd,KAA/C,CAAqD,EAArD;EACA,CAJC,CAAF;EAMAR,EAAE,CAAC,0DAAD,EAA6D,YAAM;IACpE,IAAMI,WAAW,GAAG,IAAIF,uBAAJ,CAAgB,IAAhB,EAAsB,YAAtB,EAAoCG,uBAApC,CAApB;IACAD,WAAW,CAACK,OAAZ,CAAoBF,MAApB,CAA2BC,KAA3B,CAAiC,IAAjC;IACAJ,WAAW,CAACiB,oBAAZ,GAAmCd,MAAnC,CAA0Ce,IAA1C,CAA+Cd,KAA/C,CAAqD,CAAC,IAAD,CAArD;EACA,CAJC,CAAF;EAMAR,EAAE,CAAC,2EAAD,EAA8E,YAAM;IACrF,IAAMI,WAAW,GAAG,IAAIF,uBAAJ,CAAgB,KAAhB,EAAuB,KAAvB,EAA8BG,uBAA9B,CAApB;IACAJ,MAAM,CAACG,WAAW,CAACK,OAAb,CAAN,CAA4BN,EAA5B,CAA+BgB,EAA/B,CAAkCC,SAAlC;IACAhB,WAAW,CAACiB,oBAAZ,GAAmCd,MAAnC,CAA0Ce,IAA1C,CAA+Cd,KAA/C,CAAqD,EAArD;EACA,CAJC,CAAF,CAzF6B,CA+F7B;EACA;EACA;EACA;EACA;EACA;EACA;AACA,CAtGO,CAAR"}
@@ -29,7 +29,7 @@ var _isValidCandidate = _interopRequireWildcard(require("./findNumbers/isValidCa
29
29
 
30
30
  var _metadata = require("./metadata.js");
31
31
 
32
- var _parse_ = _interopRequireDefault(require("./parse_.js"));
32
+ var _parse = _interopRequireDefault(require("./parse.js"));
33
33
 
34
34
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
35
35
 
@@ -312,7 +312,7 @@ var PhoneNumberMatcher = /*#__PURE__*/function () {
312
312
  return;
313
313
  }
314
314
 
315
- var number = (0, _parse_["default"])(candidate, {
315
+ var number = (0, _parse["default"])(candidate, {
316
316
  extended: true,
317
317
  defaultCountry: this.options.defaultCountry,
318
318
  defaultCallingCode: this.options.defaultCallingCode