@phonecheck/phone-number-validator-js 1.7.3-beta.1 → 2.0.0-beta.1

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 (520) hide show
  1. package/README.md +322 -328
  2. package/dist/cache.d.ts +17 -0
  3. package/dist/cli/format.d.ts +12 -0
  4. package/dist/cli/index.d.ts +12 -0
  5. package/dist/cli/index.js +531 -0
  6. package/dist/cli/index.js.map +1 -0
  7. package/dist/cli/parse-args.d.ts +44 -0
  8. package/dist/cli/run.d.ts +14 -0
  9. package/dist/core.d.ts +39 -0
  10. package/dist/index.d.ts +15 -0
  11. package/dist/index.esm.js +231 -0
  12. package/dist/index.esm.js.map +1 -0
  13. package/dist/index.js +254 -0
  14. package/dist/index.js.map +1 -0
  15. package/{lib → dist}/locales.d.ts +1 -2
  16. package/dist/node-fs-loader.d.ts +19 -0
  17. package/dist/serverless/_shared/cors.d.ts +6 -0
  18. package/dist/serverless/_shared/dispatch.d.ts +22 -0
  19. package/dist/serverless/_shared/lambda-helpers.d.ts +23 -0
  20. package/dist/serverless/_shared/routes.d.ts +29 -0
  21. package/dist/serverless/_shared/validation.d.ts +58 -0
  22. package/dist/serverless/_shared/web-helpers.d.ts +17 -0
  23. package/dist/serverless/adapters/aws-lambda.cjs.js +7357 -0
  24. package/dist/serverless/adapters/aws-lambda.cjs.js.map +1 -0
  25. package/dist/serverless/adapters/aws-lambda.d.ts +50 -0
  26. package/dist/serverless/adapters/aws-lambda.esm.js +7349 -0
  27. package/dist/serverless/adapters/aws-lambda.esm.js.map +1 -0
  28. package/dist/serverless/adapters/azure.cjs.js +7334 -0
  29. package/dist/serverless/adapters/azure.cjs.js.map +1 -0
  30. package/dist/serverless/adapters/azure.d.ts +32 -0
  31. package/dist/serverless/adapters/azure.esm.js +7328 -0
  32. package/dist/serverless/adapters/azure.esm.js.map +1 -0
  33. package/dist/serverless/adapters/cloudflare.cjs.js +7854 -0
  34. package/dist/serverless/adapters/cloudflare.cjs.js.map +1 -0
  35. package/dist/serverless/adapters/cloudflare.d.ts +68 -0
  36. package/dist/serverless/adapters/cloudflare.esm.js +7848 -0
  37. package/dist/serverless/adapters/cloudflare.esm.js.map +1 -0
  38. package/dist/serverless/adapters/gcp.cjs.js +7338 -0
  39. package/dist/serverless/adapters/gcp.cjs.js.map +1 -0
  40. package/dist/serverless/adapters/gcp.d.ts +22 -0
  41. package/dist/serverless/adapters/gcp.esm.js +7332 -0
  42. package/dist/serverless/adapters/gcp.esm.js.map +1 -0
  43. package/dist/serverless/adapters/netlify.cjs.js +7331 -0
  44. package/dist/serverless/adapters/netlify.cjs.js.map +1 -0
  45. package/dist/serverless/adapters/netlify.d.ts +29 -0
  46. package/dist/serverless/adapters/netlify.esm.js +7325 -0
  47. package/dist/serverless/adapters/netlify.esm.js.map +1 -0
  48. package/dist/serverless/adapters/vercel.cjs.js +7417 -0
  49. package/dist/serverless/adapters/vercel.cjs.js.map +1 -0
  50. package/dist/serverless/adapters/vercel.d.ts +30 -0
  51. package/dist/serverless/adapters/vercel.esm.js +7409 -0
  52. package/dist/serverless/adapters/vercel.esm.js.map +1 -0
  53. package/dist/serverless/index.cjs.js +12759 -0
  54. package/dist/serverless/index.cjs.js.map +1 -0
  55. package/dist/serverless/index.d.ts +14 -0
  56. package/dist/serverless/index.esm.js +12680 -0
  57. package/dist/serverless/index.esm.js.map +1 -0
  58. package/dist/serverless/loaders/fetch-loader.d.ts +39 -0
  59. package/dist/serverless/loaders/kv-loader.d.ts +27 -0
  60. package/{lib/serverless.cjs.js → dist/serverless/verifier.cjs.js} +4247 -4208
  61. package/dist/serverless/verifier.cjs.js.map +1 -0
  62. package/dist/serverless/verifier.d.ts +17 -0
  63. package/{lib/serverless.esm.js → dist/serverless/verifier.esm.js} +4242 -4209
  64. package/dist/serverless/verifier.esm.js.map +1 -0
  65. package/{lib/serverless.umd.min.js → dist/serverless/verifier.min.js} +1 -8
  66. package/dist/types.d.ts +49 -0
  67. package/package.json +111 -44
  68. package/lib/index.d.ts +0 -41
  69. package/lib/index.d.ts.map +0 -1
  70. package/lib/index.es.js +0 -113
  71. package/lib/index.js +0 -126
  72. package/lib/index.serverless.d.ts +0 -18
  73. package/lib/index.serverless.d.ts.map +0 -1
  74. package/lib/locales.d.ts.map +0 -1
  75. package/lib/serverless.esm.min.js +0 -8
  76. package/lib/serverless.umd.js +0 -11924
  77. package/resources/carrier/ar/965.bson +0 -0
  78. package/resources/carrier/be/375.bson +0 -0
  79. package/resources/carrier/en/1.bson +0 -0
  80. package/resources/carrier/en/20.bson +0 -0
  81. package/resources/carrier/en/211.bson +0 -0
  82. package/resources/carrier/en/212.bson +0 -0
  83. package/resources/carrier/en/213.bson +0 -0
  84. package/resources/carrier/en/216.bson +0 -0
  85. package/resources/carrier/en/218.bson +0 -0
  86. package/resources/carrier/en/220.bson +0 -0
  87. package/resources/carrier/en/221.bson +0 -0
  88. package/resources/carrier/en/222.bson +0 -0
  89. package/resources/carrier/en/223.bson +0 -0
  90. package/resources/carrier/en/224.bson +0 -0
  91. package/resources/carrier/en/225.bson +0 -0
  92. package/resources/carrier/en/226.bson +0 -0
  93. package/resources/carrier/en/227.bson +0 -0
  94. package/resources/carrier/en/228.bson +0 -0
  95. package/resources/carrier/en/229.bson +0 -0
  96. package/resources/carrier/en/230.bson +0 -0
  97. package/resources/carrier/en/231.bson +0 -0
  98. package/resources/carrier/en/232.bson +0 -0
  99. package/resources/carrier/en/233.bson +0 -0
  100. package/resources/carrier/en/234.bson +0 -0
  101. package/resources/carrier/en/235.bson +0 -0
  102. package/resources/carrier/en/236.bson +0 -0
  103. package/resources/carrier/en/237.bson +0 -0
  104. package/resources/carrier/en/238.bson +0 -0
  105. package/resources/carrier/en/239.bson +0 -0
  106. package/resources/carrier/en/240.bson +0 -0
  107. package/resources/carrier/en/241.bson +0 -0
  108. package/resources/carrier/en/242.bson +0 -0
  109. package/resources/carrier/en/243.bson +0 -0
  110. package/resources/carrier/en/244.bson +0 -0
  111. package/resources/carrier/en/245.bson +0 -0
  112. package/resources/carrier/en/246.bson +0 -0
  113. package/resources/carrier/en/247.bson +0 -0
  114. package/resources/carrier/en/248.bson +0 -0
  115. package/resources/carrier/en/249.bson +0 -0
  116. package/resources/carrier/en/250.bson +0 -0
  117. package/resources/carrier/en/251.bson +0 -0
  118. package/resources/carrier/en/252.bson +0 -0
  119. package/resources/carrier/en/253.bson +0 -0
  120. package/resources/carrier/en/254.bson +0 -0
  121. package/resources/carrier/en/255.bson +0 -0
  122. package/resources/carrier/en/256.bson +0 -0
  123. package/resources/carrier/en/257.bson +0 -0
  124. package/resources/carrier/en/258.bson +0 -0
  125. package/resources/carrier/en/260.bson +0 -0
  126. package/resources/carrier/en/261.bson +0 -0
  127. package/resources/carrier/en/262.bson +0 -0
  128. package/resources/carrier/en/263.bson +0 -0
  129. package/resources/carrier/en/264.bson +0 -0
  130. package/resources/carrier/en/265.bson +0 -0
  131. package/resources/carrier/en/266.bson +0 -0
  132. package/resources/carrier/en/267.bson +0 -0
  133. package/resources/carrier/en/268.bson +0 -0
  134. package/resources/carrier/en/269.bson +0 -0
  135. package/resources/carrier/en/27.bson +0 -0
  136. package/resources/carrier/en/290.bson +0 -0
  137. package/resources/carrier/en/291.bson +0 -0
  138. package/resources/carrier/en/297.bson +0 -0
  139. package/resources/carrier/en/298.bson +0 -0
  140. package/resources/carrier/en/299.bson +0 -0
  141. package/resources/carrier/en/30.bson +0 -0
  142. package/resources/carrier/en/31.bson +0 -0
  143. package/resources/carrier/en/32.bson +0 -0
  144. package/resources/carrier/en/33.bson +0 -0
  145. package/resources/carrier/en/34.bson +0 -0
  146. package/resources/carrier/en/350.bson +0 -0
  147. package/resources/carrier/en/351.bson +0 -0
  148. package/resources/carrier/en/352.bson +0 -0
  149. package/resources/carrier/en/353.bson +0 -0
  150. package/resources/carrier/en/354.bson +0 -0
  151. package/resources/carrier/en/355.bson +0 -0
  152. package/resources/carrier/en/356.bson +0 -0
  153. package/resources/carrier/en/357.bson +0 -0
  154. package/resources/carrier/en/358.bson +0 -0
  155. package/resources/carrier/en/359.bson +0 -0
  156. package/resources/carrier/en/36.bson +0 -0
  157. package/resources/carrier/en/370.bson +0 -0
  158. package/resources/carrier/en/371.bson +0 -0
  159. package/resources/carrier/en/372.bson +0 -0
  160. package/resources/carrier/en/373.bson +0 -0
  161. package/resources/carrier/en/374.bson +0 -0
  162. package/resources/carrier/en/375.bson +0 -0
  163. package/resources/carrier/en/376.bson +0 -0
  164. package/resources/carrier/en/377.bson +0 -0
  165. package/resources/carrier/en/378.bson +0 -0
  166. package/resources/carrier/en/380.bson +0 -0
  167. package/resources/carrier/en/381.bson +0 -0
  168. package/resources/carrier/en/382.bson +0 -0
  169. package/resources/carrier/en/383.bson +0 -0
  170. package/resources/carrier/en/385.bson +0 -0
  171. package/resources/carrier/en/386.bson +0 -0
  172. package/resources/carrier/en/387.bson +0 -0
  173. package/resources/carrier/en/389.bson +0 -0
  174. package/resources/carrier/en/39.bson +0 -0
  175. package/resources/carrier/en/40.bson +0 -0
  176. package/resources/carrier/en/41.bson +0 -0
  177. package/resources/carrier/en/420.bson +0 -0
  178. package/resources/carrier/en/421.bson +0 -0
  179. package/resources/carrier/en/423.bson +0 -0
  180. package/resources/carrier/en/43.bson +0 -0
  181. package/resources/carrier/en/44.bson +0 -0
  182. package/resources/carrier/en/45.bson +0 -0
  183. package/resources/carrier/en/46.bson +0 -0
  184. package/resources/carrier/en/47.bson +0 -0
  185. package/resources/carrier/en/48.bson +0 -0
  186. package/resources/carrier/en/49.bson +0 -0
  187. package/resources/carrier/en/500.bson +0 -0
  188. package/resources/carrier/en/501.bson +0 -0
  189. package/resources/carrier/en/502.bson +0 -0
  190. package/resources/carrier/en/503.bson +0 -0
  191. package/resources/carrier/en/504.bson +0 -0
  192. package/resources/carrier/en/505.bson +0 -0
  193. package/resources/carrier/en/506.bson +0 -0
  194. package/resources/carrier/en/507.bson +0 -0
  195. package/resources/carrier/en/508.bson +0 -0
  196. package/resources/carrier/en/509.bson +0 -0
  197. package/resources/carrier/en/51.bson +0 -0
  198. package/resources/carrier/en/53.bson +0 -0
  199. package/resources/carrier/en/55.bson +0 -0
  200. package/resources/carrier/en/56.bson +0 -0
  201. package/resources/carrier/en/57.bson +0 -0
  202. package/resources/carrier/en/58.bson +0 -0
  203. package/resources/carrier/en/590.bson +0 -0
  204. package/resources/carrier/en/591.bson +0 -0
  205. package/resources/carrier/en/592.bson +0 -0
  206. package/resources/carrier/en/593.bson +0 -0
  207. package/resources/carrier/en/594.bson +0 -0
  208. package/resources/carrier/en/595.bson +0 -0
  209. package/resources/carrier/en/596.bson +0 -0
  210. package/resources/carrier/en/597.bson +0 -0
  211. package/resources/carrier/en/598.bson +0 -0
  212. package/resources/carrier/en/599.bson +0 -0
  213. package/resources/carrier/en/60.bson +0 -0
  214. package/resources/carrier/en/61.bson +0 -0
  215. package/resources/carrier/en/62.bson +0 -0
  216. package/resources/carrier/en/63.bson +0 -0
  217. package/resources/carrier/en/64.bson +0 -0
  218. package/resources/carrier/en/65.bson +0 -0
  219. package/resources/carrier/en/66.bson +0 -0
  220. package/resources/carrier/en/670.bson +0 -0
  221. package/resources/carrier/en/672.bson +0 -0
  222. package/resources/carrier/en/673.bson +0 -0
  223. package/resources/carrier/en/674.bson +0 -0
  224. package/resources/carrier/en/675.bson +0 -0
  225. package/resources/carrier/en/676.bson +0 -0
  226. package/resources/carrier/en/677.bson +0 -0
  227. package/resources/carrier/en/678.bson +0 -0
  228. package/resources/carrier/en/679.bson +0 -0
  229. package/resources/carrier/en/680.bson +0 -0
  230. package/resources/carrier/en/681.bson +0 -0
  231. package/resources/carrier/en/682.bson +0 -0
  232. package/resources/carrier/en/683.bson +0 -0
  233. package/resources/carrier/en/685.bson +0 -0
  234. package/resources/carrier/en/686.bson +0 -0
  235. package/resources/carrier/en/687.bson +0 -0
  236. package/resources/carrier/en/688.bson +0 -0
  237. package/resources/carrier/en/689.bson +0 -0
  238. package/resources/carrier/en/690.bson +0 -0
  239. package/resources/carrier/en/691.bson +0 -0
  240. package/resources/carrier/en/692.bson +0 -0
  241. package/resources/carrier/en/7.bson +0 -0
  242. package/resources/carrier/en/81.bson +0 -0
  243. package/resources/carrier/en/82.bson +0 -0
  244. package/resources/carrier/en/84.bson +0 -0
  245. package/resources/carrier/en/850.bson +0 -0
  246. package/resources/carrier/en/852.bson +0 -0
  247. package/resources/carrier/en/853.bson +0 -0
  248. package/resources/carrier/en/855.bson +0 -0
  249. package/resources/carrier/en/856.bson +0 -0
  250. package/resources/carrier/en/86.bson +0 -0
  251. package/resources/carrier/en/880.bson +0 -0
  252. package/resources/carrier/en/881.bson +0 -0
  253. package/resources/carrier/en/882.bson +0 -0
  254. package/resources/carrier/en/886.bson +0 -0
  255. package/resources/carrier/en/90.bson +0 -0
  256. package/resources/carrier/en/91.bson +0 -0
  257. package/resources/carrier/en/92.bson +0 -0
  258. package/resources/carrier/en/93.bson +0 -0
  259. package/resources/carrier/en/94.bson +0 -0
  260. package/resources/carrier/en/95.bson +0 -0
  261. package/resources/carrier/en/960.bson +0 -0
  262. package/resources/carrier/en/961.bson +0 -0
  263. package/resources/carrier/en/962.bson +0 -0
  264. package/resources/carrier/en/963.bson +0 -0
  265. package/resources/carrier/en/964.bson +0 -0
  266. package/resources/carrier/en/965.bson +0 -0
  267. package/resources/carrier/en/966.bson +0 -0
  268. package/resources/carrier/en/967.bson +0 -0
  269. package/resources/carrier/en/968.bson +0 -0
  270. package/resources/carrier/en/970.bson +0 -0
  271. package/resources/carrier/en/971.bson +0 -0
  272. package/resources/carrier/en/972.bson +0 -0
  273. package/resources/carrier/en/973.bson +0 -0
  274. package/resources/carrier/en/974.bson +0 -0
  275. package/resources/carrier/en/975.bson +0 -0
  276. package/resources/carrier/en/976.bson +0 -0
  277. package/resources/carrier/en/977.bson +0 -0
  278. package/resources/carrier/en/98.bson +0 -0
  279. package/resources/carrier/en/992.bson +0 -0
  280. package/resources/carrier/en/993.bson +0 -0
  281. package/resources/carrier/en/994.bson +0 -0
  282. package/resources/carrier/en/995.bson +0 -0
  283. package/resources/carrier/en/996.bson +0 -0
  284. package/resources/carrier/en/998.bson +0 -0
  285. package/resources/carrier/fa/93.bson +0 -0
  286. package/resources/carrier/fa/98.bson +0 -0
  287. package/resources/carrier/ko/82.bson +0 -0
  288. package/resources/carrier/ru/374.bson +0 -0
  289. package/resources/carrier/ru/375.bson +0 -0
  290. package/resources/carrier/ru/7.bson +0 -0
  291. package/resources/carrier/uk/380.bson +0 -0
  292. package/resources/carrier/zh/852.bson +0 -0
  293. package/resources/carrier/zh/86.bson +0 -0
  294. package/resources/carrier/zh_Hant/852.bson +0 -0
  295. package/resources/carrier/zh_Hant/86.bson +0 -0
  296. package/resources/geocodes/ar/966.bson +0 -0
  297. package/resources/geocodes/be/375.bson +0 -0
  298. package/resources/geocodes/bg/359.bson +0 -0
  299. package/resources/geocodes/bs/387.bson +0 -0
  300. package/resources/geocodes/de/32.bson +0 -0
  301. package/resources/geocodes/de/352.bson +0 -0
  302. package/resources/geocodes/de/41.bson +0 -0
  303. package/resources/geocodes/de/43.bson +0 -0
  304. package/resources/geocodes/de/49.bson +0 -0
  305. package/resources/geocodes/el/30.bson +0 -0
  306. package/resources/geocodes/en/1.bson +0 -0
  307. package/resources/geocodes/en/20.bson +0 -0
  308. package/resources/geocodes/en/212.bson +0 -0
  309. package/resources/geocodes/en/213.bson +0 -0
  310. package/resources/geocodes/en/216.bson +0 -0
  311. package/resources/geocodes/en/218.bson +0 -0
  312. package/resources/geocodes/en/220.bson +0 -0
  313. package/resources/geocodes/en/221.bson +0 -0
  314. package/resources/geocodes/en/222.bson +0 -0
  315. package/resources/geocodes/en/223.bson +0 -0
  316. package/resources/geocodes/en/224.bson +0 -0
  317. package/resources/geocodes/en/225.bson +0 -0
  318. package/resources/geocodes/en/226.bson +0 -0
  319. package/resources/geocodes/en/227.bson +0 -0
  320. package/resources/geocodes/en/228.bson +0 -0
  321. package/resources/geocodes/en/229.bson +0 -0
  322. package/resources/geocodes/en/230.bson +0 -0
  323. package/resources/geocodes/en/232.bson +0 -0
  324. package/resources/geocodes/en/233.bson +0 -0
  325. package/resources/geocodes/en/234.bson +0 -0
  326. package/resources/geocodes/en/236.bson +0 -0
  327. package/resources/geocodes/en/237.bson +0 -0
  328. package/resources/geocodes/en/238.bson +0 -0
  329. package/resources/geocodes/en/239.bson +0 -0
  330. package/resources/geocodes/en/240.bson +0 -0
  331. package/resources/geocodes/en/241.bson +0 -0
  332. package/resources/geocodes/en/242.bson +0 -0
  333. package/resources/geocodes/en/243.bson +0 -0
  334. package/resources/geocodes/en/244.bson +0 -0
  335. package/resources/geocodes/en/245.bson +0 -0
  336. package/resources/geocodes/en/247.bson +0 -0
  337. package/resources/geocodes/en/249.bson +0 -0
  338. package/resources/geocodes/en/251.bson +0 -0
  339. package/resources/geocodes/en/252.bson +0 -0
  340. package/resources/geocodes/en/254.bson +0 -0
  341. package/resources/geocodes/en/255.bson +0 -0
  342. package/resources/geocodes/en/256.bson +0 -0
  343. package/resources/geocodes/en/257.bson +0 -0
  344. package/resources/geocodes/en/258.bson +0 -0
  345. package/resources/geocodes/en/260.bson +0 -0
  346. package/resources/geocodes/en/261.bson +0 -0
  347. package/resources/geocodes/en/263.bson +0 -0
  348. package/resources/geocodes/en/264.bson +0 -0
  349. package/resources/geocodes/en/266.bson +0 -0
  350. package/resources/geocodes/en/267.bson +0 -0
  351. package/resources/geocodes/en/268.bson +0 -0
  352. package/resources/geocodes/en/269.bson +0 -0
  353. package/resources/geocodes/en/27.bson +0 -0
  354. package/resources/geocodes/en/290.bson +0 -0
  355. package/resources/geocodes/en/299.bson +0 -0
  356. package/resources/geocodes/en/30.bson +0 -0
  357. package/resources/geocodes/en/31.bson +0 -0
  358. package/resources/geocodes/en/32.bson +0 -0
  359. package/resources/geocodes/en/34.bson +0 -0
  360. package/resources/geocodes/en/351.bson +0 -0
  361. package/resources/geocodes/en/352.bson +0 -0
  362. package/resources/geocodes/en/353.bson +0 -0
  363. package/resources/geocodes/en/354.bson +0 -0
  364. package/resources/geocodes/en/355.bson +0 -0
  365. package/resources/geocodes/en/358.bson +0 -0
  366. package/resources/geocodes/en/359.bson +0 -0
  367. package/resources/geocodes/en/36.bson +0 -0
  368. package/resources/geocodes/en/370.bson +0 -0
  369. package/resources/geocodes/en/373.bson +0 -0
  370. package/resources/geocodes/en/374.bson +0 -0
  371. package/resources/geocodes/en/375.bson +0 -0
  372. package/resources/geocodes/en/380.bson +0 -0
  373. package/resources/geocodes/en/381.bson +0 -0
  374. package/resources/geocodes/en/382.bson +0 -0
  375. package/resources/geocodes/en/383.bson +0 -0
  376. package/resources/geocodes/en/385.bson +0 -0
  377. package/resources/geocodes/en/386.bson +0 -0
  378. package/resources/geocodes/en/387.bson +0 -0
  379. package/resources/geocodes/en/389.bson +0 -0
  380. package/resources/geocodes/en/39.bson +0 -0
  381. package/resources/geocodes/en/40.bson +0 -0
  382. package/resources/geocodes/en/41.bson +0 -0
  383. package/resources/geocodes/en/420.bson +0 -0
  384. package/resources/geocodes/en/421.bson +0 -0
  385. package/resources/geocodes/en/43.bson +0 -0
  386. package/resources/geocodes/en/44.bson +0 -0
  387. package/resources/geocodes/en/46.bson +0 -0
  388. package/resources/geocodes/en/47.bson +0 -0
  389. package/resources/geocodes/en/48.bson +0 -0
  390. package/resources/geocodes/en/49.bson +0 -0
  391. package/resources/geocodes/en/501.bson +0 -0
  392. package/resources/geocodes/en/504.bson +0 -0
  393. package/resources/geocodes/en/51.bson +0 -0
  394. package/resources/geocodes/en/52.bson +0 -0
  395. package/resources/geocodes/en/53.bson +0 -0
  396. package/resources/geocodes/en/54.bson +0 -0
  397. package/resources/geocodes/en/55.bson +0 -0
  398. package/resources/geocodes/en/56.bson +0 -0
  399. package/resources/geocodes/en/57.bson +0 -0
  400. package/resources/geocodes/en/58.bson +0 -0
  401. package/resources/geocodes/en/592.bson +0 -0
  402. package/resources/geocodes/en/593.bson +0 -0
  403. package/resources/geocodes/en/595.bson +0 -0
  404. package/resources/geocodes/en/598.bson +0 -0
  405. package/resources/geocodes/en/599.bson +0 -0
  406. package/resources/geocodes/en/61.bson +0 -0
  407. package/resources/geocodes/en/62.bson +0 -0
  408. package/resources/geocodes/en/63.bson +0 -0
  409. package/resources/geocodes/en/64.bson +0 -0
  410. package/resources/geocodes/en/66.bson +0 -0
  411. package/resources/geocodes/en/670.bson +0 -0
  412. package/resources/geocodes/en/672.bson +0 -0
  413. package/resources/geocodes/en/673.bson +0 -0
  414. package/resources/geocodes/en/675.bson +0 -0
  415. package/resources/geocodes/en/676.bson +0 -0
  416. package/resources/geocodes/en/678.bson +0 -0
  417. package/resources/geocodes/en/679.bson +0 -0
  418. package/resources/geocodes/en/680.bson +0 -0
  419. package/resources/geocodes/en/682.bson +0 -0
  420. package/resources/geocodes/en/685.bson +0 -0
  421. package/resources/geocodes/en/686.bson +0 -0
  422. package/resources/geocodes/en/688.bson +0 -0
  423. package/resources/geocodes/en/689.bson +0 -0
  424. package/resources/geocodes/en/690.bson +0 -0
  425. package/resources/geocodes/en/7.bson +0 -0
  426. package/resources/geocodes/en/81.bson +0 -0
  427. package/resources/geocodes/en/82.bson +0 -0
  428. package/resources/geocodes/en/84.bson +0 -0
  429. package/resources/geocodes/en/850.bson +0 -0
  430. package/resources/geocodes/en/86.bson +0 -0
  431. package/resources/geocodes/en/880.bson +0 -0
  432. package/resources/geocodes/en/886.bson +0 -0
  433. package/resources/geocodes/en/90.bson +0 -0
  434. package/resources/geocodes/en/91.bson +0 -0
  435. package/resources/geocodes/en/92.bson +0 -0
  436. package/resources/geocodes/en/93.bson +0 -0
  437. package/resources/geocodes/en/94.bson +0 -0
  438. package/resources/geocodes/en/95.bson +0 -0
  439. package/resources/geocodes/en/960.bson +0 -0
  440. package/resources/geocodes/en/961.bson +0 -0
  441. package/resources/geocodes/en/962.bson +0 -0
  442. package/resources/geocodes/en/963.bson +0 -0
  443. package/resources/geocodes/en/966.bson +0 -0
  444. package/resources/geocodes/en/967.bson +0 -0
  445. package/resources/geocodes/en/968.bson +0 -0
  446. package/resources/geocodes/en/970.bson +0 -0
  447. package/resources/geocodes/en/971.bson +0 -0
  448. package/resources/geocodes/en/972.bson +0 -0
  449. package/resources/geocodes/en/975.bson +0 -0
  450. package/resources/geocodes/en/976.bson +0 -0
  451. package/resources/geocodes/en/98.bson +0 -0
  452. package/resources/geocodes/en/992.bson +0 -0
  453. package/resources/geocodes/en/993.bson +0 -0
  454. package/resources/geocodes/en/994.bson +0 -0
  455. package/resources/geocodes/en/995.bson +0 -0
  456. package/resources/geocodes/en/996.bson +0 -0
  457. package/resources/geocodes/es/228.bson +0 -0
  458. package/resources/geocodes/es/230.bson +0 -0
  459. package/resources/geocodes/es/34.bson +0 -0
  460. package/resources/geocodes/es/52.bson +0 -0
  461. package/resources/geocodes/es/54.bson +0 -0
  462. package/resources/geocodes/es/56.bson +0 -0
  463. package/resources/geocodes/es/57.bson +0 -0
  464. package/resources/geocodes/es/58.bson +0 -0
  465. package/resources/geocodes/fa/93.bson +0 -0
  466. package/resources/geocodes/fa/98.bson +0 -0
  467. package/resources/geocodes/fi/358.bson +0 -0
  468. package/resources/geocodes/fr/212.bson +0 -0
  469. package/resources/geocodes/fr/222.bson +0 -0
  470. package/resources/geocodes/fr/225.bson +0 -0
  471. package/resources/geocodes/fr/228.bson +0 -0
  472. package/resources/geocodes/fr/229.bson +0 -0
  473. package/resources/geocodes/fr/230.bson +0 -0
  474. package/resources/geocodes/fr/242.bson +0 -0
  475. package/resources/geocodes/fr/243.bson +0 -0
  476. package/resources/geocodes/fr/269.bson +0 -0
  477. package/resources/geocodes/fr/290.bson +0 -0
  478. package/resources/geocodes/fr/32.bson +0 -0
  479. package/resources/geocodes/fr/352.bson +0 -0
  480. package/resources/geocodes/fr/41.bson +0 -0
  481. package/resources/geocodes/hr/387.bson +0 -0
  482. package/resources/geocodes/hu/36.bson +0 -0
  483. package/resources/geocodes/hy/374.bson +0 -0
  484. package/resources/geocodes/id/62.bson +0 -0
  485. package/resources/geocodes/it/39.bson +0 -0
  486. package/resources/geocodes/it/41.bson +0 -0
  487. package/resources/geocodes/iw/972.bson +0 -0
  488. package/resources/geocodes/ja/81.bson +0 -0
  489. package/resources/geocodes/kk/7.bson +0 -0
  490. package/resources/geocodes/ko/82.bson +0 -0
  491. package/resources/geocodes/nl/31.bson +0 -0
  492. package/resources/geocodes/nl/32.bson +0 -0
  493. package/resources/geocodes/pl/48.bson +0 -0
  494. package/resources/geocodes/pt/238.bson +0 -0
  495. package/resources/geocodes/pt/239.bson +0 -0
  496. package/resources/geocodes/pt/244.bson +0 -0
  497. package/resources/geocodes/pt/245.bson +0 -0
  498. package/resources/geocodes/pt/258.bson +0 -0
  499. package/resources/geocodes/pt/351.bson +0 -0
  500. package/resources/geocodes/pt/55.bson +0 -0
  501. package/resources/geocodes/ro/373.bson +0 -0
  502. package/resources/geocodes/ro/40.bson +0 -0
  503. package/resources/geocodes/ru/373.bson +0 -0
  504. package/resources/geocodes/ru/374.bson +0 -0
  505. package/resources/geocodes/ru/375.bson +0 -0
  506. package/resources/geocodes/ru/7.bson +0 -0
  507. package/resources/geocodes/sq/383.bson +0 -0
  508. package/resources/geocodes/sr/381.bson +0 -0
  509. package/resources/geocodes/sr/383.bson +0 -0
  510. package/resources/geocodes/sr/387.bson +0 -0
  511. package/resources/geocodes/sv/358.bson +0 -0
  512. package/resources/geocodes/sv/46.bson +0 -0
  513. package/resources/geocodes/th/66.bson +0 -0
  514. package/resources/geocodes/tr/90.bson +0 -0
  515. package/resources/geocodes/uk/380.bson +0 -0
  516. package/resources/geocodes/vi/84.bson +0 -0
  517. package/resources/geocodes/zh/86.bson +0 -0
  518. package/resources/geocodes/zh/886.bson +0 -0
  519. package/resources/geocodes/zh_Hant/886.bson +0 -0
  520. package/resources/timezones.bson +0 -0
package/README.md CHANGED
@@ -1,426 +1,420 @@
1
- # Phone Number information lookup, validation, carrier name, geo and timezone infos
1
+ # Advanced Phone Number Validator
2
2
 
3
3
  [![NPM version](https://badgen.net/npm/v/@phonecheck/phone-number-validator-js)](https://npm.im/@phonecheck/phone-number-validator-js)
4
4
  [![Build Status](https://github.com/phone-check-app/phone-number-validator-js/workflows/CI/badge.svg)](https://github.com/phone-check-app/phone-number-validator-js/actions)
5
5
  [![Downloads](https://img.shields.io/npm/dm/@phonecheck/phone-number-validator-js.svg)](https://www.npmjs.com/package/@phonecheck/phone-number-validator-js)
6
6
  [![UNPKG](https://img.shields.io/badge/UNPKG-OK-179BD7.svg)](https://unpkg.com/browse/@phonecheck/phone-number-validator-js@latest/)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
8
+
9
+ 🚀 **Validate, parse, and enrich international phone numbers** — geocoding,
10
+ carrier lookup, timezone resolution, and number-type detection. Built on
11
+ [Google libphonenumber](https://github.com/google/libphonenumber)'s metadata,
12
+ distributed as compact BSON tables, served from sync (Node) and async (edge /
13
+ serverless) APIs, with first-class adapters for **AWS Lambda, Vercel,
14
+ Cloudflare Workers, GCP Cloud Functions, Netlify, and Azure Functions**.
15
+
16
+ ## 📋 Table of Contents
17
+
18
+ - [Features](#features)
19
+ - [Use Cases](#use-cases)
20
+ - [API / Cloud Service](#api--cloud-hosted-service)
21
+ - [Installation](#installation)
22
+ - [Quick Start](#quick-start)
23
+ - [API Reference](#api-reference)
24
+ - [Examples](#examples)
25
+ - [Command-line Tool (`phone-validate`)](#command-line-tool-phone-validate)
26
+ - [Cache Management](#cache-management)
27
+ - [Custom Resource Loaders](#custom-resource-loaders)
28
+ - [Serverless Usage](#serverless-usage)
29
+ - [Performance](#performance)
30
+ - [Testing](#testing)
31
+ - [Architecture](#architecture)
32
+ - [Contributing](#contributing)
33
+ - [Documentation index](#documentation-index)
7
34
 
8
- ### Verify phone number, validate format, checking carrier name, geo and timezone infos.
35
+ ## Features
9
36
 
10
- > This library includes phone number lookup and validation, and the geocoding, carrier mapping and timezone mapping functionalities that are available in some of googles [libphonenumber](https://github.com/google/libphonenumber) libraries.
11
- >
12
- > To reduce the amount of data that needs to be loaded to geocode / carrier map a phone-number for each mapping only the relevant number prefixes are loaded from a binary json file (BSON).
13
- When the prefix could not be found in the provided locale the library tries to fall back to `en` as locale.
14
- >
15
- > The library supports Node.js only at the moment.
37
+ - **E.164 / national / international parsing** via libphonenumber-js (re-exported)
38
+ - ✅ **Geocoder** — city / region in 30+ locales with English fallback
39
+ - **Original carrier mapping** Google's carrier-allocation tables
40
+ - **Timezone resolution** IANA zone IDs from the E.164 number
41
+ - ✅ **Number-type detection** — mobile, fixed-line, VoIP, toll-free, premium…
42
+ - **Sync + async parity** — `geocoder` for Node, `geocoderAsync` for edge / KV
43
+ - ✅ **Pluggable resource loader** — `node:fs`, `fetch`, Cloudflare KV, or your own
44
+ - ✅ **High-performance LRU cache** for deserialized BSON tables
45
+ - ✅ **Six platform adapters** — AWS / Vercel / Cloudflare / GCP / Netlify / Azure
46
+ - ✅ **`phone-validate` CLI** — single-shot validation + JSON logging
47
+ - ✅ **Strict TypeScript** — zero `any` and zero non-null assertions in `src/`
48
+
49
+ ## Use Cases
50
+
51
+ - Reduce SMS bounce rate by filtering invalid numbers before send
52
+ - Geo-route inbound calls or messages to the right region / carrier
53
+ - Detect VoIP / toll-free / premium-rate numbers in fraud screens
54
+ - Normalize numbers to E.164 for storage and analytics
55
+ - Protect signup / checkout forms from fake numbers and bots
56
+ - Embed validation in mobile, web, and back-office workflows
16
57
 
58
+ ## API / Cloud Hosted Service
17
59
 
18
- ## Features
19
- Check phone number validity
60
+ We offer this — and more advanced features — as a scalable cloud API:
61
+ [**Phone Number Verification**](https://phone-check.app/products/phone).
20
62
 
21
- ✅ Check phone number format
63
+ ---
22
64
 
23
- Check phone number carrier name
65
+ ## Installation
24
66
 
25
- ✅ Check phone number geolocation (city)
67
+ ```bash
68
+ bun add @phonecheck/phone-number-validator-js
69
+ # or
70
+ npm install @phonecheck/phone-number-validator-js
71
+ # or
72
+ pnpm add @phonecheck/phone-number-validator-js
73
+ ```
26
74
 
27
- Check phone number timezone
75
+ ### Requirements (consumers)
76
+ - Node.js >= 22 (Maintenance LTS) — the published bundle is plain Node.js + ESM/CJS
77
+ - TypeScript >= 4.0 (for TypeScript users)
28
78
 
29
- Check phone number country code
79
+ ### Requirements (contributing)
80
+ - Bun >= 1.3 (test runner, package manager, dev tooling)
81
+ - Node.js >= 24 only needed for `semantic-release` during the publish step
30
82
 
31
- High-performance LRU caching with configurable size
83
+ ### Build System
84
+ - Rollup builds CJS + ESM bundles for the main package and per-platform serverless adapters
85
+ - `bun test` for the unit + isolated suites (no jest, no ts-jest)
86
+ - BSON resource tables (geocodes, carrier mappings, timezones) ship under
87
+ `resources/` next to the published `dist/`
32
88
 
33
- Comprehensive error handling and input validation
89
+ ## Quick Start
34
90
 
35
- ✅ TypeScript support with strict type safety
91
+ ```typescript
92
+ import {
93
+ carrier,
94
+ geocoder,
95
+ parsePhoneNumberFromString,
96
+ timezones,
97
+ } from '@phonecheck/phone-number-validator-js';
36
98
 
37
- Serverless architecture support (AWS Lambda, Cloudflare Workers, Vercel Edge, Deno)
99
+ const phone = parsePhoneNumberFromString('+41431234567');
38
100
 
101
+ geocoder(phone); // → "Zurich"
102
+ geocoder(phone, 'de'); // → "Zürich"
103
+ carrier(parsePhoneNumberFromString('01701234567', 'DE'));
104
+ // → "T-Mobile"
105
+ timezones(parsePhoneNumberFromString('+12124567890'));
106
+ // → ["America/New_York"]
107
+ ```
39
108
 
40
- ## Use cases
41
- - Increase delivery rate of SMS campaigns by removing invalid phone numbers
42
- - Increase SMS open rate and your marketing IPs reputation
43
- - Protect your website from spam, bots and fake phone numbers
44
- - Protect your product signup form from fake phone numbers
45
- - Protect your website forms from fake phone numbers
46
- - Protect your self from fraud orders and accounts using fake phone numbers
47
- - Integrate phone number verification into your website forms
48
- - Integrate phone number verification into your backoffice administration and order processing
49
- - Integrate phone number verification into your mobile apps
109
+ For a one-shot enrichment call:
50
110
 
51
- ## API / Cloud Hosted Service
52
- We offer this `phone verification and validation and more advanced features` in our Scalable Cloud API Service Offering - You could try it here [Phone Number Verification](https://phone-check.app/products/phone)
111
+ ```typescript
112
+ import { enrichPhoneNumber, parsePhoneNumberFromString }
113
+ from '@phonecheck/phone-number-validator-js';
114
+
115
+ const phone = parsePhoneNumberFromString('+8619912345678');
116
+ await enrichPhoneNumber(phone, { carrierLocale: 'zh' });
117
+ // {
118
+ // geocode: "Hubei",
119
+ // carrier: "中国电信",
120
+ // timezones: ["Asia/Shanghai", ...]
121
+ // }
122
+ ```
53
123
 
54
- ---
124
+ ## API Reference
55
125
 
56
- ## installation and usage instructions
126
+ ### Core Functions
57
127
 
58
- ## Installation
128
+ #### `geocoder(phone, locale = 'en'): string | null`
59
129
 
60
- ```sh
61
- npm install @phonecheck/phone-number-validator-js
62
- ```
130
+ Resolve a city / region for the given parsed phone number. Returns `null` for
131
+ landline-only ranges, unknown country codes, or invalid input. Falls back to
132
+ English when the locale-specific table is missing.
63
133
 
64
- or
134
+ #### `carrier(phone, locale = 'en'): string | null`
65
135
 
66
- ```sh
67
- yarn add @phonecheck/phone-number-validator-js
68
- ```
136
+ Resolve the **original** carrier from Google's carrier-allocation tables.
137
+ Note this does **not** reflect ports — see [the upstream FAQ][lpn-carrier].
138
+ Returns `null` for landlines and unmapped ranges.
69
139
 
70
- ## Usage
140
+ [lpn-carrier]: https://github.com/google/libphonenumber#mapping-phone-numbers-to-original-carriers
71
141
 
72
- ### Core Methods
142
+ #### `timezones(phone): string[] | null`
73
143
 
74
- - `geocoder(phonenumber: PhoneNumber, locale?: GeocoderLocale = 'en'): string | null` - Resolved to the geocode or null if no geocode could be found (e.g. for mobile numbers)
75
- - `carrier(phonenumber: PhoneNumber, locale?: CarrierLocale = 'en'): string | null` - Resolves to the carrier or null if non could be found (e.g. for fixed line numbers)
76
- - `timezones(phonenumber: PhoneNumber): Array<string> | null` - Resolved to an array of timezones or null if non where found.
144
+ Resolve one or more IANA timezone IDs for the given E.164 number.
77
145
 
78
- ### Cache Management Methods
146
+ #### Async variants
79
147
 
80
- - `clearCache(): void` - Clear all cached data
81
- - `getCacheSize(): number` - Get current cache size
82
- - `setCacheSize(size: number): void` - Set maximum cache size (default: 100)
148
+ Same signatures, returning a `Promise`:
83
149
 
84
- ## Examples
150
+ - `geocoderAsync(phone, locale?)`
151
+ - `carrierAsync(phone, locale?)`
152
+ - `timezonesAsync(phone)`
153
+ - `enrichPhoneNumber(phone, options?)` — runs all three in parallel
85
154
 
86
- ### Basic Usage
155
+ The async variants only require `loader.loadResource`. The sync ones require
156
+ `loader.loadResourceSync`. The bundled `NodeFsResourceLoader` provides both.
87
157
 
88
- ```js
89
- import { geocoder, carrier, timezones, parsePhoneNumberFromString } from '@phonecheck/phone-number-validator-js'
158
+ ### Cache
90
159
 
91
- const fixedLineNumber = parsePhoneNumberFromString('+41431234567')
92
- const locationEN = geocoder(fixedLineNumber) // Zurich
93
- const locationDE = geocoder(fixedLineNumber, 'de') // Zürich
94
- const locationIT = geocoder(fixedLineNumber, 'it') // Zurigo
160
+ ```typescript
161
+ import {
162
+ clearCache,
163
+ DEFAULT_CACHE_SIZE, // 100
164
+ getCacheSize,
165
+ getCacheStats, // { size, maxSize }
166
+ setCacheSize,
167
+ } from '@phonecheck/phone-number-validator-js';
168
+ ```
95
169
 
96
- const mobileNumber = parsePhoneNumberFromString('+8619912345678')
97
- const carrierEN = carrier(mobileNumber) // China Telecom
98
- const carrierZH = carrier(mobileNumber, 'zh') // 中国电信
170
+ The cache stores deserialized BSON tables (one per `country-code/locale`
171
+ pair). Resize for memory-tight environments, clear it for tests / long-running
172
+ workers.
99
173
 
100
- const fixedLineNumber2 = parsePhoneNumberFromString('+49301234567')
101
- const tzones = timezones(fixedLineNumber2) // ['Europe/Berlin']
102
- ```
174
+ ### Resource loaders
103
175
 
104
- ### Cache Management
176
+ ```typescript
177
+ import { NodeFsResourceLoader, setResourceLoader }
178
+ from '@phonecheck/phone-number-validator-js';
105
179
 
106
- ```js
107
- import {
108
- clearCache,
109
- getCacheSize,
110
- setCacheSize,
111
- geocoder,
112
- parsePhoneNumberFromString
113
- } from '@phonecheck/phone-number-validator-js'
180
+ setResourceLoader(new NodeFsResourceLoader({ resourcesDir: '/custom/path' }));
181
+ ```
114
182
 
115
- // Adjust cache size based on your needs
116
- setCacheSize(50) // Limit to 50 entries
183
+ The Node entry installs a default loader pointing at the bundled `resources/`.
184
+ Swap it for serverless / edge — see [Custom Resource Loaders](#custom-resource-loaders).
117
185
 
118
- // Monitor cache usage
119
- console.log(`Cache size: ${getCacheSize()}`)
186
+ ### Re-exports
120
187
 
121
- // Perform lookups
122
- const phoneNumber = parsePhoneNumberFromString('+41431234567')
123
- const location = geocoder(phoneNumber)
188
+ Everything from `libphonenumber-js` is re-exported under the same name —
189
+ `parsePhoneNumberFromString`, `parsePhoneNumberWithError`, `PhoneNumber`,
190
+ `CountryCode`, formatters, etc. One import covers parsing + enrichment.
124
191
 
125
- // Clear cache when needed
126
- if (getCacheSize() > 40) {
127
- clearCache()
128
- }
192
+ ### Locale types
193
+
194
+ `GeocoderLocale` and `CarrierLocale` are union types listing the supported
195
+ locales (auto-generated by `scripts/prepare-metadata.ts`). Use them for
196
+ exhaustive switches:
129
197
 
130
- // For long-running processes, you might want to clear cache periodically
131
- setInterval(() => {
132
- clearCache()
133
- }, 3600000) // Clear every hour
198
+ ```typescript
199
+ import type { GeocoderLocale } from '@phonecheck/phone-number-validator-js';
134
200
  ```
135
201
 
136
- ### Error Handling
202
+ ## Examples
137
203
 
138
- ```js
139
- import { geocoder, parsePhoneNumberFromString } from '@phonecheck/phone-number-validator-js'
204
+ ### Detecting number type
140
205
 
141
- // Invalid phone numbers return null
142
- const invalid = parsePhoneNumberFromString('invalid')
143
- const result = geocoder(invalid) // null
206
+ ```typescript
207
+ import { parsePhoneNumberFromString } from '@phonecheck/phone-number-validator-js';
144
208
 
145
- // Undefined/null inputs are handled gracefully
146
- const result2 = geocoder(undefined) // null
147
- const result3 = geocoder(null) // null
209
+ const phone = parsePhoneNumberFromString('+14155552671');
210
+ phone?.getType(); // 'FIXED_LINE_OR_MOBILE'
148
211
  ```
149
212
 
150
- ### TypeScript Usage
213
+ ### Validating + formatting in one pass
151
214
 
152
215
  ```typescript
153
- import {
154
- geocoder,
155
- carrier,
156
- timezones,
157
- parsePhoneNumberFromString,
158
- PhoneNumber,
159
- GeocoderLocale,
160
- CarrierLocale
161
- } from '@phonecheck/phone-number-validator-js'
216
+ import { parsePhoneNumberFromString } from '@phonecheck/phone-number-validator-js';
162
217
 
163
- // Type-safe locale usage
164
- const phoneNumber: PhoneNumber | undefined = parsePhoneNumberFromString('+41431234567')
165
- const locale: GeocoderLocale = 'de'
218
+ function normalize(input: string): string | null {
219
+ const phone = parsePhoneNumberFromString(input, 'US');
220
+ if (!phone?.isValid()) return null;
221
+ return phone.format('E.164');
222
+ }
223
+
224
+ normalize('(415) 555-2671'); // '+14155552671'
225
+ normalize('not a number'); // null
226
+ ```
166
227
 
167
- const location: string | null = geocoder(phoneNumber, locale)
168
- const carrierInfo: string | null = carrier(phoneNumber)
169
- const tzs: string[] | null = timezones(phoneNumber)
228
+ ### Iterating with locale fallback
170
229
 
171
- // Cache management with types
172
- import { setCacheSize, getCacheSize, clearCache } from '@phonecheck/phone-number-validator-js'
230
+ ```typescript
231
+ import { geocoder, parsePhoneNumberFromString }
232
+ from '@phonecheck/phone-number-validator-js';
173
233
 
174
- const size: number = getCacheSize()
175
- setCacheSize(50)
176
- clearCache()
234
+ const numbers = ['+41431234567', '+8619912345678', '+12124567890'];
235
+ for (const n of numbers) {
236
+ console.log(n, '→', geocoder(parsePhoneNumberFromString(n), 'de'));
237
+ }
238
+ // +41431234567 → Zürich (de table)
239
+ // +8619912345678 → Hubei (en fallback — no de carrier table for 86)
240
+ // +12124567890 → New York (en fallback)
177
241
  ```
178
242
 
179
- ## Serverless Support
243
+ ## Command-line Tool (`phone-validate`)
180
244
 
181
- The library provides a lightweight serverless version that's optimized for edge environments like AWS Lambda, Cloudflare Workers, Vercel Edge Functions, and Deno Deploy.
245
+ Installing the package globally exposes a `phone-validate` binary:
182
246
 
183
- ### Features
184
- - **244KB bundle size** (minified) - fits well under most size limits
185
- - **No Node.js dependencies** - runs in any JavaScript environment
186
- - **Resource loader pattern** - load data from your preferred storage (S3, R2, KV, etc.)
187
- - **Same API** - drop-in replacement for the standard version
247
+ ```bash
248
+ $ bun add -g @phonecheck/phone-number-validator-js
249
+ $ phone-validate +14155552671
250
+ ```
188
251
 
189
- ### Installation for Serverless
252
+ ```text
253
+ ✓ VALID +14155552671
190
254
 
191
- ```js
192
- // Use the serverless entry point
193
- import {
194
- setResourceLoader,
195
- parsePhoneNumber,
196
- geocoder,
197
- carrier,
198
- timezones
199
- } from '@phonecheck/phone-number-validator-js/serverless'
200
- ```
255
+ Summary
256
+ country: US (+1)
257
+ type: FIXED_LINE_OR_MOBILE
201
258
 
202
- ### Serverless Examples
203
-
204
- #### AWS Lambda
205
- ```js
206
- import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3'
207
- import { setResourceLoader, geocoder, parsePhoneNumber } from '@phonecheck/phone-number-validator-js/serverless'
208
-
209
- const s3 = new S3Client()
210
-
211
- // Set up resource loader
212
- setResourceLoader({
213
- async loadResource(path) {
214
- try {
215
- const command = new GetObjectCommand({
216
- Bucket: process.env.RESOURCES_BUCKET,
217
- Key: `phone-validator/${path}`
218
- })
219
- const response = await s3.send(command)
220
- return new Uint8Array(await response.Body.transformToByteArray())
221
- } catch {
222
- return null
223
- }
224
- }
225
- })
226
-
227
- // Lambda handler
228
- export async function handler(event) {
229
- const phoneNumber = parsePhoneNumber(event.phone, event.country)
230
- const location = await geocoder(phoneNumber)
231
-
232
- return {
233
- statusCode: 200,
234
- body: JSON.stringify({ location })
235
- }
236
- }
259
+ Formatted
260
+ E.164: +14155552671
261
+ national: (415) 555-2671
262
+ international: +1 415 555 2671
263
+ RFC3966: tel:+14155552671
264
+
265
+ Enrichment
266
+ geocode: San Francisco
267
+ timezones: America/Los_Angeles
237
268
  ```
238
269
 
239
- #### Cloudflare Workers
240
- ```js
241
- import { setResourceLoader, carrier, parsePhoneNumber } from '@phonecheck/phone-number-validator-js/serverless'
242
-
243
- // Use R2 storage for resources
244
- setResourceLoader({
245
- async loadResource(path) {
246
- const object = await env.RESOURCES_BUCKET.get(`phone-validator/${path}`)
247
- if (!object) return null
248
- const buffer = await object.arrayBuffer()
249
- return new Uint8Array(buffer)
250
- }
251
- })
252
-
253
- export default {
254
- async fetch(request, env) {
255
- const url = new URL(request.url)
256
- const phone = url.searchParams.get('phone')
257
-
258
- const phoneNumber = parsePhoneNumber(phone)
259
- const carrierInfo = await carrier(phoneNumber)
260
-
261
- return Response.json({ carrier: carrierInfo })
262
- }
263
- }
270
+ Output formats:
271
+
272
+ ```bash
273
+ phone-validate +14155552671 --format json --quiet --no-log-file | jq
274
+ phone-validate "(415) 555-2671" --country US --format text
264
275
  ```
265
276
 
266
- #### Vercel Edge Functions
267
- ```js
268
- import { setResourceLoader, timezones, parsePhoneNumber } from '@phonecheck/phone-number-validator-js/serverless'
269
-
270
- // Use Vercel Blob storage
271
- setResourceLoader({
272
- async loadResource(path) {
273
- const response = await fetch(`${process.env.BLOB_URL}/phone-validator/${path}`)
274
- if (!response.ok) return null
275
- const buffer = await response.arrayBuffer()
276
- return new Uint8Array(buffer)
277
- }
278
- })
277
+ Exit codes: `0` valid, `1` invalid / unparseable, `2` bad CLI args.
279
278
 
280
- export const config = { runtime: 'edge' }
279
+ Run `phone-validate --help` for the full flag list.
281
280
 
282
- export default async function handler(req) {
283
- const { phone } = await req.json()
284
- const phoneNumber = parsePhoneNumber(phone)
285
- const tzs = await timezones(phoneNumber)
286
-
287
- return Response.json({ timezones: tzs })
288
- }
281
+ ## Cache Management
282
+
283
+ ```typescript
284
+ import {
285
+ clearCache,
286
+ getCacheStats,
287
+ setCacheSize,
288
+ } from '@phonecheck/phone-number-validator-js';
289
+
290
+ setCacheSize(500); // default 100
291
+ getCacheStats(); // { size: 17, maxSize: 500 }
292
+ clearCache(); // drop all entries
289
293
  ```
290
294
 
291
- ### Resource Files
295
+ The cache is keyed by the loader path (`geocodes/en/41.bson`, …) so a single
296
+ process shares hits across the Node entry and any serverless adapter that
297
+ also runs in it.
292
298
 
293
- The serverless version requires resource files to be deployed separately. Download them from the npm package:
299
+ ## Custom Resource Loaders
294
300
 
295
- ```bash
296
- # Extract resource files from the npm package
297
- npm pack @phonecheck/phone-number-validator-js
298
- tar -xf phonecheck-phone-number-validator-js-*.tgz
299
- cp -r package/resources/* your-storage-location/
300
- ```
301
+ Implement `ResourceLoader` to host the BSON tables anywhere — KV, R2, S3, a
302
+ public CDN, an in-memory map. The loader is the only thing that changes
303
+ between runtimes; the resolver is the same.
301
304
 
302
- Then upload to your preferred storage (S3, R2, Blob storage, etc.) and configure the resource loader accordingly.
303
-
304
- ### Performance Tips
305
-
306
- 1. **Use caching**: The library includes built-in LRU caching
307
- 2. **Deploy resources to the same region** as your functions for lower latency
308
- 3. **Consider using CDN** for resource files if serving globally
309
- 4. **Use sync loader** when possible for better performance:
310
-
311
- ```js
312
- // Sync loader for environments that support it
313
- setResourceLoader({
314
- loadResourceSync(path) {
315
- // Synchronous loading implementation
316
- return loadFromCacheSync(path)
317
- },
318
- async loadResource(path) {
319
- // Async fallback
320
- return loadFromCacheAsync(path)
305
+ ```typescript
306
+ import {
307
+ setResourceLoader,
308
+ type ResourceLoader,
309
+ } from '@phonecheck/phone-number-validator-js/serverless';
310
+
311
+ class S3Loader implements ResourceLoader {
312
+ async loadResource(path: string): Promise<Uint8Array | null> {
313
+ const res = await fetch(`https://my-bucket.s3.amazonaws.com/phone/${path}`);
314
+ if (res.status === 404) return null;
315
+ if (!res.ok) throw new Error(`S3 ${res.status} for ${path}`);
316
+ return new Uint8Array(await res.arrayBuffer());
321
317
  }
322
- })
318
+ }
319
+
320
+ setResourceLoader(new S3Loader());
323
321
  ```
324
322
 
325
- For detailed serverless deployment guides, see [SERVERLESS.md](./SERVERLESS.md).
323
+ Two implementations ship in the package:
326
324
 
325
+ | Loader | Backed by | Sync? | Use when |
326
+ |-|-|-|-|
327
+ | `NodeFsResourceLoader` | `node:fs` | ✓ | Running on Node.js with the bundled `resources/` |
328
+ | `FetchResourceLoader` | `fetch` | ✗ | Tables hosted on a CDN / R2 / S3 with public reads |
329
+ | `KvResourceLoader` | Workers KV-shape | ✗ | Cloudflare KV or any KV-shaped store |
327
330
 
328
- ## Performance
331
+ ## Serverless Usage
332
+
333
+ For deployment recipes — wrangler.toml, Vercel routes, lambda zips, GCP
334
+ function entries, Netlify redirects, Azure host.json — see
335
+ **[SERVERLESS.md](./SERVERLESS.md)**.
329
336
 
330
- The library uses [tiny-lru](https://www.npmjs.com/package/tiny-lru) for high-performance caching:
337
+ A minimal Cloudflare Worker:
331
338
 
332
- - **O(1) complexity** for cache operations (get, set, delete)
333
- - **LRU eviction** when cache reaches the size limit
334
- - **Configurable cache size** to balance memory usage and performance
335
- - **<1ms lookups** after initial data load
339
+ ```typescript
340
+ // src/worker.ts
341
+ import worker from '@phonecheck/phone-number-validator-js/serverless/cloudflare';
336
342
 
337
- ## Building
343
+ // Bind PHONE_RESOURCES (KV) in wrangler.toml. The adapter auto-installs a
344
+ // loader from it.
345
+ export default worker;
346
+ ```
338
347
 
339
- Build the library for both standard and serverless environments:
348
+ ```toml
349
+ # wrangler.toml
350
+ [[kv_namespaces]]
351
+ binding = "PHONE_RESOURCES"
352
+ id = "..."
353
+ ```
340
354
 
341
355
  ```bash
342
- yarn build
356
+ $ curl -X POST https://my.workers.dev/ \
357
+ -H 'content-type: application/json' \
358
+ -d '{ "phoneNumber": "+14155552671" }'
359
+ { "success": true, "data": { "valid": true, ... } }
343
360
  ```
344
361
 
345
- This command:
346
- - Creates optimized bundles for CommonJS and ES modules
347
- - Generates TypeScript declaration files
348
- - Builds both standard and serverless versions
362
+ ## Performance
363
+
364
+ - BSON tables are loaded **once per `country-code/locale`** and cached as
365
+ decoded `Document`s.
366
+ - Default cache size is 100 entries — enough for the top ~50 country codes in
367
+ English and a fallback locale at the same time.
368
+ - Per-lookup cost after warm-up is a single object access + a `while` loop
369
+ over the prefix (~2-4 iterations on average).
370
+ - The pure verifier bundle is **~80 KB minified** (libphonenumber-js
371
+ dominates); Workers-only deployments can shrink further by importing
372
+ `/serverless/verifier` directly instead of `/serverless`.
349
373
 
350
374
  ## Testing
351
375
 
352
376
  ```bash
353
- yarn test
377
+ bun install
378
+ bun run typecheck
379
+ bun run lint
380
+ bun run test # unit + isolated, no network, no real fs
381
+ bun run test:integration # opt-in: requires bundled resources/
354
382
  ```
355
383
 
356
- Run tests in production mode (suppresses debug logs):
384
+ The unit suite uses an in-memory `MockResourceLoader` so it's fast (under a
385
+ second) and deterministic. The isolated suite exercises the bundled
386
+ `NodeFsResourceLoader` against the real `resources/` directory.
357
387
 
358
- ```bash
359
- NODE_ENV=production yarn test
360
- ```
388
+ For the full test layout, run commands, BSON-key conventions, and CI matrix,
389
+ see [TESTING.md](./TESTING.md).
390
+
391
+ ## Architecture
392
+
393
+ For the module map, request lifecycle, adapter pattern, and how the
394
+ sync/async API parity works, see [ARCHITECTURE.md](./ARCHITECTURE.md).
361
395
 
362
396
  ## Contributing
363
- Please feel free to open an issue or create a pull request and fix bugs or add features, All contributions are welcome. Thank you!
364
-
365
- ## Support
366
-
367
- For issues, questions, or commercial licensing:
368
-
369
- 🐛 [Open an Issue](https://github.com/phone-check-app/phone-number-validator-js/issues)
370
- 📧 [Email Support](mailto:support@phone-check.app)
371
- 📄 [Commercial License](https://phone-check.app/license/phone-number-validator)
372
- 🌐 [Visit phone-check.app](https://phone-check.app)
373
-
374
- ## LICENSE
375
- Business Source License 1.1 - see [LICENSE](LICENSE.md) file for details.
376
-
377
- ### 📝 When Do You Need a Commercial License?
378
-
379
- The BSL allows use only for non-production purposes. Here's a comprehensive guide to help you understand when you need a commercial license:
380
-
381
- | Use Case | Commercial License Required? | Details |
382
- |----------|-----------|---------|
383
- | **Personal & Learning** | | |
384
- | 🔬 Exploring phone-number-validator-js for research or learning | ✅ **No** | Use freely for educational purposes |
385
- | 🎨 Personal hobby projects (non-commercial) | ✅ **No** | Build personal tools and experiments |
386
- | 🧪 Testing and evaluation in development environment | ✅ **No** | Test all features before purchasing |
387
- | **Development & Prototyping** | | |
388
- | 💡 Building proof-of-concept applications | ✅ **No** | Create demos and prototypes |
389
- | 🛠️ Internal tools (not customer-facing) | ✅ **No** | Use for internal development tools |
390
- | 📚 Open source projects (non-commercial) | ✅ **No** | Contribute to the community |
391
- | **Commercial & Production Use** | | |
392
- | 💰 Revenue-generating applications | ❌ **Yes** | Any app that generates income |
393
- | ☁️ Software as a Service (SaaS) products | ❌ **Yes** | Cloud-based service offerings |
394
- | 📦 Distributed commercial software | ❌ **Yes** | Software sold to customers |
395
- | 🏢 Enterprise production systems | ❌ **Yes** | Business-critical applications |
396
- | 🔄 Forking for commercial purposes | ❌ **Yes** | Creating derivative commercial products |
397
- | 🏭 Production use in any form | ❌ **Yes** | Live systems serving real users |
398
- | **Specific Scenarios** | | |
399
- | 🎓 Student projects and coursework | ✅ **No** | Academic use is encouraged |
400
- | 🏗️ CI/CD pipelines (for commercial products) | ❌ **Yes** | Part of commercial development |
401
- | 📱 Phone validation in production APIs | ❌ **Yes** | Production service usage |
402
- | 🛒 E-commerce checkout validation | ❌ **Yes** | Revenue-related validation |
403
- | 📱 Mobile apps (free with ads or paid) | ❌ **Yes** | Monetized applications |
404
-
405
- ### 💡 Quick Decision Guide
406
-
407
- Ask yourself these questions:
408
- 1. **Will real users interact with this in production?** → You need a license
409
- 2. **Will this help generate revenue?** → You need a license
410
- 3. **Is this for learning or testing only?** → No license needed
411
- 4. **Is this an internal prototype or POC?** → No license needed
412
-
413
- ### 🎯 Why Choose Our Commercial License?
414
-
415
- ✨ **Unlimited Usage** - Use in all your production applications
416
- 🚀 **Priority Support** - Direct support from our engineering team
417
- 🔄 **Regular Updates** - Get the latest features and improvements
418
- 🛡️ **Legal Protection** - Full commercial rights and warranty
419
- 🏢 **Enterprise Ready** - Suitable for large-scale deployments
420
-
421
- ### 📄 Get Your Commercial License
422
-
423
- Ready to use phone-number-validator-js in production?
424
-
425
- 🛍️ **[Purchase a License](https://phone-check.app/license/phone-number-validator)** - Simple pricing, instant activation
426
- 📧 **[Contact Sales](mailto:sales@phone-check.app?subject=Interested%20in%20phone-number-validator-js%20commercial%20license)** - For enterprise or custom needs
397
+
398
+ - Read [AGENTS.md](./AGENTS.md) — code style, branching, commit conventions
399
+ - Branch off `develop`; PRs target `develop`
400
+ - `bun run typecheck && bun run test && bun run build` must be clean
401
+ - Conventional Commits drive the release: `feat:`, `fix:`, `perf:` are
402
+ releasable; `chore:`, `docs:`, `test:` are not
403
+ - Pre-commit hook runs Biome via `lint-staged`; please don't `--no-verify`
404
+
405
+ ## Documentation index
406
+
407
+ | Doc | What's in it |
408
+ | - | - |
409
+ | [README.md](./README.md) | Public API, quick start, CLI, examples |
410
+ | [ARCHITECTURE.md](./ARCHITECTURE.md) | Module map, data flow, adapter pattern |
411
+ | [SERVERLESS.md](./SERVERLESS.md) | AWS / Vercel / Cloudflare / GCP / Netlify / Azure deployment |
412
+ | [TESTING.md](./TESTING.md) | Test layout, run commands, BSON-key conventions |
413
+ | [AGENTS.md](./AGENTS.md) | Code-style rules, code-pattern conventions |
414
+ | [examples/README.md](./examples/README.md) | Runnable example index |
415
+ | [CHANGELOG.md](./CHANGELOG.md) | Release history (auto-managed) |
416
+ | [LICENSE.md](./LICENSE.md) | License terms |
417
+
418
+ ## License
419
+
420
+ See [LICENSE.md](./LICENSE.md).