Closed popod closed 3 years ago
There doesn't seem to be anywhere in the README where parsePhoneNumber
named export is used.
here for example : https://github.com/catamphetamine/libphonenumber-js#use
It's not a named export
Thank you for reply, but this is not clear..
import parsePhoneNumber from 'libphonenumber-js'
seems to works the same as import parsePhoneNumberWithError from 'libphonenumber-js'
but not like import parsePhoneNumberFromString from 'libphonenumber-js'
?
What does or how works : import parsePhoneNumber from 'libphonenumber-js'
(this is not documented)
I think that this could be better explained in the doc ?
You seem to be confusing "default" exports and "named" exports. https://medium.com/@etherealm/named-export-vs-default-export-in-es6-affb483a0910
thank you for reply.. yes this is my bad.. I understand "default" and "named" exports.. but in my tests I'm using require
..
const libphonenumber = require('libphonenumber-js')
libphonenumber.parsePhoneNumber() // seems to works like parsePhoneNumberWithError()
libphonenumber.parsePhoneNumberFromString()
This two functions doesn't works the same.. and this is because of that that I ask a parsePhoneNumber
documentation.
But this is okey and all works when using import
. Sorry for that !
libphonenumber.parsePhoneNumber
is a named import and is not covered in the README.
It used to exist in legacy versions.
In the readme
parsePhoneNumber
andparsePhoneNumberFromString
are used, but onlyparsePhoneNumberFromString
is describe in the API section.What is the difference between this two functions ?
I've done some tests and it seems that
parsePhoneNumber
need atry/catch
block to catch errors and thatparsePhoneNumberFromString
return an empty response in case of error..Thank you for reply