@optique/core 1.0.0-dev.745 → 1.0.0-dev.751

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ function isValueParser(object) {
14
14
  * Implementation of the choice parser for both string and number types.
15
15
  */
16
16
  function choice(choices, options = {}) {
17
+ if (choices.length < 1) throw new TypeError("Expected at least one choice, but got an empty array.");
17
18
  const metavar = options.metavar ?? "TYPE";
18
19
  require_nonempty.ensureNonEmptyString(metavar);
19
20
  const isNumberChoice = choices.length > 0 && typeof choices[0] === "number";
@@ -206,6 +206,7 @@ declare function isValueParser<M extends Mode, T>(object: unknown): object is Va
206
206
  * @param options Configuration options for the choice parser.
207
207
  * @returns A {@link ValueParser} that checks if the input matches one of the
208
208
  * specified values.
209
+ * @throws {TypeError} If the choices array is empty.
209
210
  * @throws {TypeError} If `caseInsensitive` is `true` and multiple choices
210
211
  * normalize to the same lowercase value.
211
212
  */
@@ -221,6 +222,7 @@ declare function choice<const T extends string>(choices: readonly T[], options?:
221
222
  * @param options Configuration options for the choice parser.
222
223
  * @returns A {@link ValueParser} that checks if the input matches one of the
223
224
  * specified values.
225
+ * @throws {TypeError} If the choices array is empty.
224
226
  * @since 0.9.0
225
227
  */
226
228
  declare function choice<const T extends number>(choices: readonly T[], options?: ChoiceOptionsNumber): ValueParser<"sync", T>;
@@ -206,6 +206,7 @@ declare function isValueParser<M extends Mode, T>(object: unknown): object is Va
206
206
  * @param options Configuration options for the choice parser.
207
207
  * @returns A {@link ValueParser} that checks if the input matches one of the
208
208
  * specified values.
209
+ * @throws {TypeError} If the choices array is empty.
209
210
  * @throws {TypeError} If `caseInsensitive` is `true` and multiple choices
210
211
  * normalize to the same lowercase value.
211
212
  */
@@ -221,6 +222,7 @@ declare function choice<const T extends string>(choices: readonly T[], options?:
221
222
  * @param options Configuration options for the choice parser.
222
223
  * @returns A {@link ValueParser} that checks if the input matches one of the
223
224
  * specified values.
225
+ * @throws {TypeError} If the choices array is empty.
224
226
  * @since 0.9.0
225
227
  */
226
228
  declare function choice<const T extends number>(choices: readonly T[], options?: ChoiceOptionsNumber): ValueParser<"sync", T>;
@@ -14,6 +14,7 @@ function isValueParser(object) {
14
14
  * Implementation of the choice parser for both string and number types.
15
15
  */
16
16
  function choice(choices, options = {}) {
17
+ if (choices.length < 1) throw new TypeError("Expected at least one choice, but got an empty array.");
17
18
  const metavar = options.metavar ?? "TYPE";
18
19
  ensureNonEmptyString(metavar);
19
20
  const isNumberChoice = choices.length > 0 && typeof choices[0] === "number";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.745+a12a4fbd",
3
+ "version": "1.0.0-dev.751+3ec7e203",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",