r/javascript • u/myroslavmartsin • Aug 26 '26
Telixon - phone number library that compiles Google's libphonenumber metadata into a DFA (10x faster, 26 kB)
https://github.com/martsinlabs/telixon
22
Upvotes
8
u/Ecksters Aug 26 '26 edited Aug 26 '26
I think it's helpful to know what library and its functionality this is replacing, since it's a very well documented library: https://libphonenumber.org/
Very cool optimization, although I'd love to know what application you're working in where you've gotta parse so many phone numbers
And a substantial space-savings compared to libphonenumber-js, which I would consider the closest competitor, which takes 44.6KB, minified and gzipped.
2
u/magenta_placenta Aug 26 '26
Does it handle phone extensions or does it assume those are a separate input?
0
u/myroslavmartsin Aug 26 '26
Phone libraries traditionally interpret Google's libphonenumber metadata regexes at runtime, on every parse. Telixon moves that work to build time: thousands of regexes and format rules get compiled into compact binary state tables forming one deterministic finite automaton. A parse is a linear walk, one transition per digit, and the state it ends on already holds validity, type, region, and formatting.
What the compilation buys:
And the part I care most about: every answer is verified against Google's own libphonenumber source in CI, checked out at the exact commit the metadata was compiled from, across all 245 regions on every push, plus a weekly exhaustive run over 1,838,775,900 inputs. Zero divergences: https://proof.telixon.dev/parity.html
There is also a headless input controller with real mid-string editing (caret math, undo/redo, queries mid-typing), for building phone fields: https://telixon.dev/web-sdk/guides/complete-field
Repo: https://github.com/martsinlabs/telixon
If Telixon solves a problem for you, a star on GitHub helps it reach more developers. And if something is missing or broken, open an issue. I read every one.