part of "extensions.dart";
extension StringExtension on String {
  String capitalizeFirst() {
    return "${this[0].toUpperCase()}${substring(1)}";
  }

  int checksum() {
    int hash = 0x9E370001;
    final cus = codeUnits;
    for (var cu in cus) {
      hash = hashCombine(hash, cu);
    }
    return hashFinish(hash);
  }

  int substringCount(String sub) {
    int count = 0;
    int start = 0;
    while (start < length) {
      final index = indexOf(sub, start);
      if (index < 0) {
        break;
      }
      start = index + sub.length;
      count++;
    }
    return count;
  }
}
