ts-phonenumber - v2.0.0
    Preparing search index...

    Function isNumberMatch

    • Compares two phone numbers and returns how closely they match.

      Parameters

      • firstNumber: string | ParsedPhoneNumber

        First phone number (string or ParsedPhoneNumber)

      • secondNumber: string | ParsedPhoneNumber

        Second phone number (string or ParsedPhoneNumber)

      Returns Promise<MatchType>

      MatchType indicating the level of match

      // EXACT_MATCH - same number, different formatting
      await isNumberMatch('+64 3 331 6005', '+64 03 331 6005');

      // NSN_MATCH - national numbers match, one missing country code
      await isNumberMatch('+64 3 331-6005', '03 331 6005');

      // SHORT_NSN_MATCH - one is suffix of the other
      await isNumberMatch('+64 3 331-6005', '331 6005');

      // NO_MATCH - different numbers
      await isNumberMatch('03 331 6005', '03 331 6006');