catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
https://catamphetamine.gitlab.io/libphonenumber-js/
MIT License
2.79k stars 216 forks source link

isValid() Method is not working inside try catch #281

Closed khaled9544 closed 5 years ago

khaled9544 commented 5 years ago

Hello,

isValid() is not working inside the try catch braces.

With

  async push() {
    try {
      let phoneNumber = `${this.dial_code}${this.phoneNumber}`;
      let parsedNumber = parsePhoneNumber(phoneNumber, this.code);
      console.log(parsedNumber.isValid()); //----> Always false
    } catch(e) {
      console.log(JSON.stringify(e,null,2));
    }
  };

Without

  async push() {
      let phoneNumber = `${this.dial_code}${this.phoneNumber}`;
      let parsedNumber = parsePhoneNumber(phoneNumber, this.code);
      console.log(parsedNumber.isValid()); //----> Is working well
  };

Any idea why this is happening?

Thanks

catamphetamine commented 5 years ago

You can create a sample project illustrating the issue (or a "fiddle"). Closing until then because this doesn't seem like a possible bug.