code: function check_value(val, min, max) {
      val = +val;
      if (typeof(val) != 'number' || val < min || val > max || Math.floor(val) !== val) {
          throw new TypeError("\"value\" argument is out of bounds");
      }
      return val;
  }
docs: Check that a value is an integer within the given range