<commit_before>goog.require('i18n.phonenumbers.AsYouTypeFormatter');
goog.require('i18n.phonenumbers.PhoneNumberFormat');
goog.require('i18n.phonenumbers.PhoneNumberType');
goog.require('i18n.phonenumbers.PhoneNumberUtil');
goog.require('i18n.phonenumbers.PhoneNumberUtil.ValidationResult');

var phoneUtil = i18n.phonenumbers.PhoneNumberUtil.getInstance();

// stateless AsYouTypeFormatter (pass full string to it each time)
// designed as stateless to work with ADVANCED_OPTIMIZATIONS
function formatAsTyped(phoneNumber, regionCode) {
  regionCode = regionCode || "us";

  var formatter = new i18n.phonenumbers.AsYouTypeFormatter(regionCode);

  var output;

  // loop over phone number and input digits one by one, then return final output
  if (phoneNumber && typeof phoneNumber === 'string') {
    for (var i = 0; i < phoneNumber.length; i++) {
      output = formatter.inputDigit(phoneNumber.charAt(i));
    }
  }

  return output;
}

function countryCodeToRegionCodeMap() {
  return i18n.phonenumbers.metadata.countryCodeToRegionCodeMap;
}

function isPossibleNumber(phoneNumber, regionCode) {
  regionCode = regionCode || "us";
  var number = phoneUtil.parseAndKeepRawInput(phoneNumber, regionCode);
  return phoneUtil.isPossibleNumber(number);
}
<commit_msg>Restore debugging code to formatAsTyped<commit_after>goog.require('i18n.phonenumbers.AsYouTypeFormatter');
goog.require('i18n.phonenumbers.PhoneNumberFormat');
goog.require('i18n.phonenumbers.PhoneNumberType');
goog.require('i18n.phonenumbers.PhoneNumberUtil');
goog.require('i18n.phonenumbers.PhoneNumberUtil.ValidationResult');

var phoneUtil = i18n.phonenumbers.PhoneNumberUtil.getInstance();

// stateless AsYouTypeFormatter (pass full string to it each time)
// designed as stateless to work with ADVANCED_OPTIMIZATIONS
function formatAsTyped(phoneNumber, regionCode) {
  regionCode = regionCode || "us";

  console.log('Instantiating AsYouTypeFormatter for', regionCode);

  var formatter = new i18n.phonenumbers.AsYouTypeFormatter(regionCode);

  var output;

  // loop over phone number and input digits one by one, then return final output
  if (phoneNumber && typeof phoneNumber === 'string') {
    for (var i = 0; i < phoneNumber.length; i++) {
      output = formatter.inputDigit(phoneNumber.charAt(i));
      console.log('char:', phoneNumber.charAt(i), 'output:', output);
    }
  }

  return output;
}

function countryCodeToRegionCodeMap() {
  return i18n.phonenumbers.metadata.countryCodeToRegionCodeMap;
}

function isPossibleNumber(phoneNumber, regionCode) {
  regionCode = regionCode || "us";
  var number = phoneUtil.parseAndKeepRawInput(phoneNumber, regionCode);
  return phoneUtil.isPossibleNumber(number);
}

{'fraction_non_alphanumeric': 0.11082283172720533, 'fraction_numerical': 0.012601927353595256, 'mean_word_length': 5.7984886649874054, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5065541', 'n_tokens_mistral': 882, 'n_tokens_neox': 817, 'n_words': 176}