private computeStatistics()

in javascript/packages/fury/lib/meta/MetaString.ts [388:418]


  private computeStatistics(chars: string[]) {
    let canLowerUpperDigitSpecialEncoded = true;
    let canLowerSpecialEncoded = true;
    let digitCount = 0;
    let upperCount = 0;
    for (const c of chars) {
      if (canLowerUpperDigitSpecialEncoded) {
        if (!((c >= "a" && c <= "z")
          || (c >= "A" && c <= "Z")
          || (c >= "0" && c <= "9")
          || (c === this.specialChar1 || c === this.specialChar2))) {
          // Character outside of LOWER_UPPER_DIGIT_SPECIAL set
          canLowerUpperDigitSpecialEncoded = false;
        }
      }
      if (canLowerSpecialEncoded) {
        if (!((c >= "a" && c <= "z") || (c === "." || c === "_" || c === "$" || c === "|"))) {
          // Character outside of LOWER_SPECIAL set
          canLowerSpecialEncoded = false;
        }
      }
      if (this.isDigit(c)) {
        digitCount++;
      }
      if (this.isUpperCase(c)) {
        upperCount++;
      }
    }
    return new StringStatistics(
      digitCount, upperCount, canLowerSpecialEncoded, canLowerUpperDigitSpecialEncoded);
  }