code: protected static Requirement caretRequirement(String version, Semver.SemverType type) {
          if (type != Semver.SemverType.NPM) {
              throw new SemverException("The caret requirements are only compatible with NPM.");
          }
          Semver semver = new Semver(version, type);
          Requirement req1 = new Requirement(new Range(extrapolateVersion(semver), Range.RangeOperator.GTE), null, null, null);
  
          String next;
          if (semver.getMajor() == 0) {
              if (semver.getMinor() == null) {
                  next = "1.0.0";
              } else if (semver.getMinor() == 0) {
                  if (semver.getPatch() == null) {
                      next = "0.1.0";
                  } else {
                      next = "0.0." + (semver.getPatch() + 1);
                  }
              } else {
                  next = "0." + (semver.getMinor() + 1) + ".0";
              }
          } else {
              next = (semver.getMajor() + 1) + ".0.0";
          }
          Requirement req2 = new Requirement(new Range(next, Range.RangeOperator.LT), null, null, null);
  
          return new Requirement(null, req1, RequirementOperator.AND, req2);
      }
docs: Allows changes that do not modify the left-most non-zero digit in the [major, minor, patch] tuple.