docs: private static CharSequence js_substr(CharSequence target, Object[] args) {
          if (args.length < 1)
              return target;
  
          double begin = ScriptRuntime.toInteger(args[0]);
          double end;
          int length = target.length();
  
          if (begin < 0) {
              begin += length;
              if (begin < 0)
                  begin = 0;
          } else if (begin > length) {
              begin = length;
          }
  
          if (args.length == 1) {
              end = length;
          } else {
              end = ScriptRuntime.toInteger(args[1]);
              if (end < 0)
                  end = 0;
              end += begin;
              if (end > length)
                  end = length;
          }
  
          return target.subSequence((int)begin, (int)end);
      }