@optique/core 0.10.7 → 1.0.0-dev.1109

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.
Files changed (56) hide show
  1. package/README.md +4 -6
  2. package/dist/annotations.cjs +209 -1
  3. package/dist/annotations.d.cts +78 -1
  4. package/dist/annotations.d.ts +78 -1
  5. package/dist/annotations.js +201 -1
  6. package/dist/completion.cjs +186 -50
  7. package/dist/completion.js +186 -50
  8. package/dist/constructs.cjs +310 -78
  9. package/dist/constructs.d.cts +525 -644
  10. package/dist/constructs.d.ts +525 -644
  11. package/dist/constructs.js +311 -79
  12. package/dist/context.cjs +43 -3
  13. package/dist/context.d.cts +113 -5
  14. package/dist/context.d.ts +113 -5
  15. package/dist/context.js +41 -3
  16. package/dist/dependency.cjs +172 -66
  17. package/dist/dependency.d.cts +22 -2
  18. package/dist/dependency.d.ts +22 -2
  19. package/dist/dependency.js +172 -66
  20. package/dist/doc.cjs +46 -1
  21. package/dist/doc.d.cts +24 -0
  22. package/dist/doc.d.ts +24 -0
  23. package/dist/doc.js +46 -1
  24. package/dist/facade.cjs +702 -322
  25. package/dist/facade.d.cts +124 -190
  26. package/dist/facade.d.ts +124 -190
  27. package/dist/facade.js +703 -323
  28. package/dist/index.cjs +5 -0
  29. package/dist/index.d.cts +5 -5
  30. package/dist/index.d.ts +5 -5
  31. package/dist/index.js +3 -3
  32. package/dist/message.cjs +7 -4
  33. package/dist/message.js +7 -4
  34. package/dist/mode-dispatch.cjs +23 -1
  35. package/dist/mode-dispatch.d.cts +55 -0
  36. package/dist/mode-dispatch.d.ts +55 -0
  37. package/dist/mode-dispatch.js +21 -1
  38. package/dist/modifiers.cjs +210 -55
  39. package/dist/modifiers.js +211 -56
  40. package/dist/parser.cjs +80 -47
  41. package/dist/parser.d.cts +18 -3
  42. package/dist/parser.d.ts +18 -3
  43. package/dist/parser.js +82 -50
  44. package/dist/primitives.cjs +102 -37
  45. package/dist/primitives.d.cts +81 -24
  46. package/dist/primitives.d.ts +81 -24
  47. package/dist/primitives.js +103 -39
  48. package/dist/usage.cjs +88 -6
  49. package/dist/usage.d.cts +51 -13
  50. package/dist/usage.d.ts +51 -13
  51. package/dist/usage.js +85 -7
  52. package/dist/valueparser.cjs +371 -99
  53. package/dist/valueparser.d.cts +56 -7
  54. package/dist/valueparser.d.ts +56 -7
  55. package/dist/valueparser.js +371 -99
  56. package/package.json +10 -1
@@ -1,4 +1,5 @@
1
1
  import { Message } from "./message.cjs";
2
+ import { HiddenVisibility } from "./usage.cjs";
2
3
  import { CombineModes, InferValue, Mode, Parser, ParserResult } from "./parser.cjs";
3
4
 
4
5
  //#region src/constructs.d.ts
@@ -35,7 +36,7 @@ interface OrOptions {
35
36
  /**
36
37
  * Context information about what types of inputs are expected,
37
38
  * used for generating contextual error messages.
38
- * @since 0.9.0
39
+ * @since 0.7.0
39
40
  */
40
41
  interface NoMatchContext {
41
42
  /**
@@ -105,6 +106,15 @@ declare class DuplicateOptionError extends Error {
105
106
  readonly sources: readonly (string | symbol)[];
106
107
  constructor(optionName: string, sources: readonly (string | symbol)[]);
107
108
  }
109
+ type OrParserArity = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15;
110
+ type OrArityLimitError = {
111
+ readonly __optiqueOrArityLimit: "or() requires between 1 and 15 parser arguments. Nest or() to combine more.";
112
+ };
113
+ type OrTailOptions = OrOptions & {
114
+ readonly $valueType?: never;
115
+ };
116
+ type IsTuple<T extends readonly unknown[]> = number extends T["length"] ? false : true;
117
+ type OrArityGuard<TParsers extends readonly unknown[]> = IsTuple<TParsers> extends true ? TParsers["length"] extends OrParserArity ? unknown : OrArityLimitError : unknown;
108
118
  /**
109
119
  * Creates a parser that combines two mutually exclusive parsers into one.
110
120
  * The resulting parser will try each of the provided parsers in order,
@@ -117,8 +127,9 @@ declare class DuplicateOptionError extends Error {
117
127
  * @template TStateB The type of the state used by the second parser.
118
128
  * @param a The first {@link Parser} to try.
119
129
  * @param b The second {@link Parser} to try.
120
- * @returns A {@link Parser} that tries to parse using the provided parsers
121
- * in order, returning the result of the first successful parser.
130
+ * @return A {@link Parser} that tries to parse using the provided parsers
131
+ * in order, returning the result of the first successful parser.
132
+ * @since 0.3.0
122
133
  */
123
134
  declare function or<MA extends Mode, MB extends Mode, TA, TB, TStateA, TStateB>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>): Parser<CombineModes<readonly [MA, MB]>, TA | TB, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>]>;
124
135
  /**
@@ -139,6 +150,7 @@ declare function or<MA extends Mode, MB extends Mode, TA, TB, TStateA, TStateB>(
139
150
  * @param c The third {@link Parser} to try.
140
151
  * @return A {@link Parser} that tries to parse using the provided parsers
141
152
  * in order, returning the result of the first successful parser.
153
+ * @since 0.3.0
142
154
  */
143
155
  declare function or<MA extends Mode, MB extends Mode, MC extends Mode, TA, TB, TC, TStateA, TStateB, TStateC>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>): Parser<CombineModes<readonly [MA, MB, MC]>, TA | TB | TC, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>]>;
144
156
  /**
@@ -163,6 +175,7 @@ declare function or<MA extends Mode, MB extends Mode, MC extends Mode, TA, TB, T
163
175
  * @param d The fourth {@link Parser} to try.
164
176
  * @return A {@link Parser} that tries to parse using the provided parsers
165
177
  * in order, returning the result of the first successful parser.
178
+ * @since 0.3.0
166
179
  */
167
180
  declare function or<MA extends Mode, MB extends Mode, MC extends Mode, MD extends Mode, TA, TB, TC, TD, TStateA, TStateB, TStateC, TStateD>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>, d: Parser<MD, TD, TStateD>): Parser<CombineModes<readonly [MA, MB, MC, MD]>, TA | TB | TC | TD, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>]>;
168
181
  /**
@@ -398,42 +411,365 @@ declare function or<MA extends Mode, MB extends Mode, MC extends Mode, MD extend
398
411
  * @since 0.3.0
399
412
  */
400
413
  declare function or<MA extends Mode, MB extends Mode, MC extends Mode, MD extends Mode, ME extends Mode, MF extends Mode, MG extends Mode, MH extends Mode, MI extends Mode, MJ extends Mode, TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TStateA, TStateB, TStateC, TStateD, TStateE, TStateF, TStateG, TStateH, TStateI, TStateJ>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>, d: Parser<MD, TD, TStateD>, e: Parser<ME, TE, TStateE>, f: Parser<MF, TF, TStateF>, g: Parser<MG, TG, TStateG>, h: Parser<MH, TH, TStateH>, i: Parser<MI, TI, TStateI>, j: Parser<MJ, TJ, TStateJ>): Parser<CombineModes<readonly [MA, MB, MC, MD, ME, MF, MG, MH, MI, MJ]>, TA | TB | TC | TD | TE | TF | TG | TH | TI | TJ, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>] | [4, ParserResult<TStateE>] | [5, ParserResult<TStateF>] | [6, ParserResult<TStateG>] | [7, ParserResult<TStateH>] | [8, ParserResult<TStateI>] | [9, ParserResult<TStateJ>]>;
414
+ /**
415
+ * Creates a parser that combines eleven mutually exclusive parsers into one.
416
+ * The resulting parser will try each of the provided parsers in order,
417
+ * and return the result of the first successful parser.
418
+ * @template MA The mode of the first parser.
419
+ * @template MB The mode of the second parser.
420
+ * @template MC The mode of the third parser.
421
+ * @template MD The mode of the fourth parser.
422
+ * @template ME The mode of the fifth parser.
423
+ * @template MF The mode of the sixth parser.
424
+ * @template MG The mode of the seventh parser.
425
+ * @template MH The mode of the eighth parser.
426
+ * @template MI The mode of the ninth parser.
427
+ * @template MJ The mode of the tenth parser.
428
+ * @template MK The mode of the eleventh parser.
429
+ * @template TA The type of the value returned by the first parser.
430
+ * @template TB The type of the value returned by the second parser.
431
+ * @template TC The type of the value returned by the third parser.
432
+ * @template TD The type of the value returned by the fourth parser.
433
+ * @template TE The type of the value returned by the fifth parser.
434
+ * @template TF The type of the value returned by the sixth parser.
435
+ * @template TG The type of the value returned by the seventh parser.
436
+ * @template TH The type of the value returned by the eighth parser.
437
+ * @template TI The type of the value returned by the ninth parser.
438
+ * @template TJ The type of the value returned by the tenth parser.
439
+ * @template TK The type of the value returned by the eleventh parser.
440
+ * @template TStateA The type of the state used by the first parser.
441
+ * @template TStateB The type of the state used by the second parser.
442
+ * @template TStateC The type of the state used by the third parser.
443
+ * @template TStateD The type of the state used by the fourth parser.
444
+ * @template TStateE The type of the state used by the fifth parser.
445
+ * @template TStateF The type of the state used by the sixth parser.
446
+ * @template TStateG The type of the state used by the seventh parser.
447
+ * @template TStateH The type of the state used by the eighth parser.
448
+ * @template TStateI The type of the state used by the ninth parser.
449
+ * @template TStateJ The type of the state used by the tenth parser.
450
+ * @template TStateK The type of the state used by the eleventh parser.
451
+ * @param a The first {@link Parser} to try.
452
+ * @param b The second {@link Parser} to try.
453
+ * @param c The third {@link Parser} to try.
454
+ * @param d The fourth {@link Parser} to try.
455
+ * @param e The fifth {@link Parser} to try.
456
+ * @param f The sixth {@link Parser} to try.
457
+ * @param g The seventh {@link Parser} to try.
458
+ * @param h The eighth {@link Parser} to try.
459
+ * @param i The ninth {@link Parser} to try.
460
+ * @param j The tenth {@link Parser} to try.
461
+ * @param k The eleventh {@link Parser} to try.
462
+ * @return A {@link Parser} that tries to parse using the provided parsers
463
+ * in order, returning the result of the first successful parser.
464
+ * @since 1.0.0
465
+ */
466
+ declare function or<MA extends Mode, MB extends Mode, MC extends Mode, MD extends Mode, ME extends Mode, MF extends Mode, MG extends Mode, MH extends Mode, MI extends Mode, MJ extends Mode, MK extends Mode, TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TStateA, TStateB, TStateC, TStateD, TStateE, TStateF, TStateG, TStateH, TStateI, TStateJ, TStateK>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>, d: Parser<MD, TD, TStateD>, e: Parser<ME, TE, TStateE>, f: Parser<MF, TF, TStateF>, g: Parser<MG, TG, TStateG>, h: Parser<MH, TH, TStateH>, i: Parser<MI, TI, TStateI>, j: Parser<MJ, TJ, TStateJ>, k: Parser<MK, TK, TStateK>): Parser<CombineModes<readonly [MA, MB, MC, MD, ME, MF, MG, MH, MI, MJ, MK]>, TA | TB | TC | TD | TE | TF | TG | TH | TI | TJ | TK, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>] | [4, ParserResult<TStateE>] | [5, ParserResult<TStateF>] | [6, ParserResult<TStateG>] | [7, ParserResult<TStateH>] | [8, ParserResult<TStateI>] | [9, ParserResult<TStateJ>] | [10, ParserResult<TStateK>]>;
467
+ /**
468
+ * Creates a parser that combines twelve mutually exclusive parsers into one.
469
+ * The resulting parser will try each of the provided parsers in order,
470
+ * and return the result of the first successful parser.
471
+ * @template MA The mode of the first parser.
472
+ * @template MB The mode of the second parser.
473
+ * @template MC The mode of the third parser.
474
+ * @template MD The mode of the fourth parser.
475
+ * @template ME The mode of the fifth parser.
476
+ * @template MF The mode of the sixth parser.
477
+ * @template MG The mode of the seventh parser.
478
+ * @template MH The mode of the eighth parser.
479
+ * @template MI The mode of the ninth parser.
480
+ * @template MJ The mode of the tenth parser.
481
+ * @template MK The mode of the eleventh parser.
482
+ * @template ML The mode of the twelfth parser.
483
+ * @template TA The type of the value returned by the first parser.
484
+ * @template TB The type of the value returned by the second parser.
485
+ * @template TC The type of the value returned by the third parser.
486
+ * @template TD The type of the value returned by the fourth parser.
487
+ * @template TE The type of the value returned by the fifth parser.
488
+ * @template TF The type of the value returned by the sixth parser.
489
+ * @template TG The type of the value returned by the seventh parser.
490
+ * @template TH The type of the value returned by the eighth parser.
491
+ * @template TI The type of the value returned by the ninth parser.
492
+ * @template TJ The type of the value returned by the tenth parser.
493
+ * @template TK The type of the value returned by the eleventh parser.
494
+ * @template TL The type of the value returned by the twelfth parser.
495
+ * @template TStateA The type of the state used by the first parser.
496
+ * @template TStateB The type of the state used by the second parser.
497
+ * @template TStateC The type of the state used by the third parser.
498
+ * @template TStateD The type of the state used by the fourth parser.
499
+ * @template TStateE The type of the state used by the fifth parser.
500
+ * @template TStateF The type of the state used by the sixth parser.
501
+ * @template TStateG The type of the state used by the seventh parser.
502
+ * @template TStateH The type of the state used by the eighth parser.
503
+ * @template TStateI The type of the state used by the ninth parser.
504
+ * @template TStateJ The type of the state used by the tenth parser.
505
+ * @template TStateK The type of the state used by the eleventh parser.
506
+ * @template TStateL The type of the state used by the twelfth parser.
507
+ * @param a The first {@link Parser} to try.
508
+ * @param b The second {@link Parser} to try.
509
+ * @param c The third {@link Parser} to try.
510
+ * @param d The fourth {@link Parser} to try.
511
+ * @param e The fifth {@link Parser} to try.
512
+ * @param f The sixth {@link Parser} to try.
513
+ * @param g The seventh {@link Parser} to try.
514
+ * @param h The eighth {@link Parser} to try.
515
+ * @param i The ninth {@link Parser} to try.
516
+ * @param j The tenth {@link Parser} to try.
517
+ * @param k The eleventh {@link Parser} to try.
518
+ * @param l The twelfth {@link Parser} to try.
519
+ * @return A {@link Parser} that tries to parse using the provided parsers
520
+ * in order, returning the result of the first successful parser.
521
+ * @since 1.0.0
522
+ */
523
+ declare function or<MA extends Mode, MB extends Mode, MC extends Mode, MD extends Mode, ME extends Mode, MF extends Mode, MG extends Mode, MH extends Mode, MI extends Mode, MJ extends Mode, MK extends Mode, ML extends Mode, TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TL, TStateA, TStateB, TStateC, TStateD, TStateE, TStateF, TStateG, TStateH, TStateI, TStateJ, TStateK, TStateL>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>, d: Parser<MD, TD, TStateD>, e: Parser<ME, TE, TStateE>, f: Parser<MF, TF, TStateF>, g: Parser<MG, TG, TStateG>, h: Parser<MH, TH, TStateH>, i: Parser<MI, TI, TStateI>, j: Parser<MJ, TJ, TStateJ>, k: Parser<MK, TK, TStateK>, l: Parser<ML, TL, TStateL>): Parser<CombineModes<readonly [MA, MB, MC, MD, ME, MF, MG, MH, MI, MJ, MK, ML]>, TA | TB | TC | TD | TE | TF | TG | TH | TI | TJ | TK | TL, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>] | [4, ParserResult<TStateE>] | [5, ParserResult<TStateF>] | [6, ParserResult<TStateG>] | [7, ParserResult<TStateH>] | [8, ParserResult<TStateI>] | [9, ParserResult<TStateJ>] | [10, ParserResult<TStateK>] | [11, ParserResult<TStateL>]>;
524
+ /**
525
+ * Creates a parser that combines thirteen mutually exclusive parsers into one.
526
+ * The resulting parser will try each of the provided parsers in order,
527
+ * and return the result of the first successful parser.
528
+ * @template MA The mode of the first parser.
529
+ * @template MB The mode of the second parser.
530
+ * @template MC The mode of the third parser.
531
+ * @template MD The mode of the fourth parser.
532
+ * @template ME The mode of the fifth parser.
533
+ * @template MF The mode of the sixth parser.
534
+ * @template MG The mode of the seventh parser.
535
+ * @template MH The mode of the eighth parser.
536
+ * @template MI The mode of the ninth parser.
537
+ * @template MJ The mode of the tenth parser.
538
+ * @template MK The mode of the eleventh parser.
539
+ * @template ML The mode of the twelfth parser.
540
+ * @template MM The mode of the thirteenth parser.
541
+ * @template TA The type of the value returned by the first parser.
542
+ * @template TB The type of the value returned by the second parser.
543
+ * @template TC The type of the value returned by the third parser.
544
+ * @template TD The type of the value returned by the fourth parser.
545
+ * @template TE The type of the value returned by the fifth parser.
546
+ * @template TF The type of the value returned by the sixth parser.
547
+ * @template TG The type of the value returned by the seventh parser.
548
+ * @template TH The type of the value returned by the eighth parser.
549
+ * @template TI The type of the value returned by the ninth parser.
550
+ * @template TJ The type of the value returned by the tenth parser.
551
+ * @template TK The type of the value returned by the eleventh parser.
552
+ * @template TL The type of the value returned by the twelfth parser.
553
+ * @template TM The type of the value returned by the thirteenth parser.
554
+ * @template TStateA The type of the state used by the first parser.
555
+ * @template TStateB The type of the state used by the second parser.
556
+ * @template TStateC The type of the state used by the third parser.
557
+ * @template TStateD The type of the state used by the fourth parser.
558
+ * @template TStateE The type of the state used by the fifth parser.
559
+ * @template TStateF The type of the state used by the sixth parser.
560
+ * @template TStateG The type of the state used by the seventh parser.
561
+ * @template TStateH The type of the state used by the eighth parser.
562
+ * @template TStateI The type of the state used by the ninth parser.
563
+ * @template TStateJ The type of the state used by the tenth parser.
564
+ * @template TStateK The type of the state used by the eleventh parser.
565
+ * @template TStateL The type of the state used by the twelfth parser.
566
+ * @template TStateM The type of the state used by the thirteenth parser.
567
+ * @param a The first {@link Parser} to try.
568
+ * @param b The second {@link Parser} to try.
569
+ * @param c The third {@link Parser} to try.
570
+ * @param d The fourth {@link Parser} to try.
571
+ * @param e The fifth {@link Parser} to try.
572
+ * @param f The sixth {@link Parser} to try.
573
+ * @param g The seventh {@link Parser} to try.
574
+ * @param h The eighth {@link Parser} to try.
575
+ * @param i The ninth {@link Parser} to try.
576
+ * @param j The tenth {@link Parser} to try.
577
+ * @param k The eleventh {@link Parser} to try.
578
+ * @param l The twelfth {@link Parser} to try.
579
+ * @param m The thirteenth {@link Parser} to try.
580
+ * @return A {@link Parser} that tries to parse using the provided parsers
581
+ * in order, returning the result of the first successful parser.
582
+ * @since 1.0.0
583
+ */
584
+ declare function or<MA extends Mode, MB extends Mode, MC extends Mode, MD extends Mode, ME extends Mode, MF extends Mode, MG extends Mode, MH extends Mode, MI extends Mode, MJ extends Mode, MK extends Mode, ML extends Mode, MM extends Mode, TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TL, TM, TStateA, TStateB, TStateC, TStateD, TStateE, TStateF, TStateG, TStateH, TStateI, TStateJ, TStateK, TStateL, TStateM>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>, d: Parser<MD, TD, TStateD>, e: Parser<ME, TE, TStateE>, f: Parser<MF, TF, TStateF>, g: Parser<MG, TG, TStateG>, h: Parser<MH, TH, TStateH>, i: Parser<MI, TI, TStateI>, j: Parser<MJ, TJ, TStateJ>, k: Parser<MK, TK, TStateK>, l: Parser<ML, TL, TStateL>, m: Parser<MM, TM, TStateM>): Parser<CombineModes<readonly [MA, MB, MC, MD, ME, MF, MG, MH, MI, MJ, MK, ML, MM]>, TA | TB | TC | TD | TE | TF | TG | TH | TI | TJ | TK | TL | TM, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>] | [4, ParserResult<TStateE>] | [5, ParserResult<TStateF>] | [6, ParserResult<TStateG>] | [7, ParserResult<TStateH>] | [8, ParserResult<TStateI>] | [9, ParserResult<TStateJ>] | [10, ParserResult<TStateK>] | [11, ParserResult<TStateL>] | [12, ParserResult<TStateM>]>;
585
+ /**
586
+ * Creates a parser that combines fourteen mutually exclusive parsers into one.
587
+ * The resulting parser will try each of the provided parsers in order,
588
+ * and return the result of the first successful parser.
589
+ * @template MA The mode of the first parser.
590
+ * @template MB The mode of the second parser.
591
+ * @template MC The mode of the third parser.
592
+ * @template MD The mode of the fourth parser.
593
+ * @template ME The mode of the fifth parser.
594
+ * @template MF The mode of the sixth parser.
595
+ * @template MG The mode of the seventh parser.
596
+ * @template MH The mode of the eighth parser.
597
+ * @template MI The mode of the ninth parser.
598
+ * @template MJ The mode of the tenth parser.
599
+ * @template MK The mode of the eleventh parser.
600
+ * @template ML The mode of the twelfth parser.
601
+ * @template MM The mode of the thirteenth parser.
602
+ * @template MN The mode of the fourteenth parser.
603
+ * @template TA The type of the value returned by the first parser.
604
+ * @template TB The type of the value returned by the second parser.
605
+ * @template TC The type of the value returned by the third parser.
606
+ * @template TD The type of the value returned by the fourth parser.
607
+ * @template TE The type of the value returned by the fifth parser.
608
+ * @template TF The type of the value returned by the sixth parser.
609
+ * @template TG The type of the value returned by the seventh parser.
610
+ * @template TH The type of the value returned by the eighth parser.
611
+ * @template TI The type of the value returned by the ninth parser.
612
+ * @template TJ The type of the value returned by the tenth parser.
613
+ * @template TK The type of the value returned by the eleventh parser.
614
+ * @template TL The type of the value returned by the twelfth parser.
615
+ * @template TM The type of the value returned by the thirteenth parser.
616
+ * @template TN The type of the value returned by the fourteenth parser.
617
+ * @template TStateA The type of the state used by the first parser.
618
+ * @template TStateB The type of the state used by the second parser.
619
+ * @template TStateC The type of the state used by the third parser.
620
+ * @template TStateD The type of the state used by the fourth parser.
621
+ * @template TStateE The type of the state used by the fifth parser.
622
+ * @template TStateF The type of the state used by the sixth parser.
623
+ * @template TStateG The type of the state used by the seventh parser.
624
+ * @template TStateH The type of the state used by the eighth parser.
625
+ * @template TStateI The type of the state used by the ninth parser.
626
+ * @template TStateJ The type of the state used by the tenth parser.
627
+ * @template TStateK The type of the state used by the eleventh parser.
628
+ * @template TStateL The type of the state used by the twelfth parser.
629
+ * @template TStateM The type of the state used by the thirteenth parser.
630
+ * @template TStateN The type of the state used by the fourteenth parser.
631
+ * @param a The first {@link Parser} to try.
632
+ * @param b The second {@link Parser} to try.
633
+ * @param c The third {@link Parser} to try.
634
+ * @param d The fourth {@link Parser} to try.
635
+ * @param e The fifth {@link Parser} to try.
636
+ * @param f The sixth {@link Parser} to try.
637
+ * @param g The seventh {@link Parser} to try.
638
+ * @param h The eighth {@link Parser} to try.
639
+ * @param i The ninth {@link Parser} to try.
640
+ * @param j The tenth {@link Parser} to try.
641
+ * @param k The eleventh {@link Parser} to try.
642
+ * @param l The twelfth {@link Parser} to try.
643
+ * @param m The thirteenth {@link Parser} to try.
644
+ * @param n The fourteenth {@link Parser} to try.
645
+ * @return A {@link Parser} that tries to parse using the provided parsers
646
+ * in order, returning the result of the first successful parser.
647
+ * @since 1.0.0
648
+ */
649
+ declare function or<MA extends Mode, MB extends Mode, MC extends Mode, MD extends Mode, ME extends Mode, MF extends Mode, MG extends Mode, MH extends Mode, MI extends Mode, MJ extends Mode, MK extends Mode, ML extends Mode, MM extends Mode, MN extends Mode, TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TL, TM, TN, TStateA, TStateB, TStateC, TStateD, TStateE, TStateF, TStateG, TStateH, TStateI, TStateJ, TStateK, TStateL, TStateM, TStateN>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>, d: Parser<MD, TD, TStateD>, e: Parser<ME, TE, TStateE>, f: Parser<MF, TF, TStateF>, g: Parser<MG, TG, TStateG>, h: Parser<MH, TH, TStateH>, i: Parser<MI, TI, TStateI>, j: Parser<MJ, TJ, TStateJ>, k: Parser<MK, TK, TStateK>, l: Parser<ML, TL, TStateL>, m: Parser<MM, TM, TStateM>, n: Parser<MN, TN, TStateN>): Parser<CombineModes<readonly [MA, MB, MC, MD, ME, MF, MG, MH, MI, MJ, MK, ML, MM, MN]>, TA | TB | TC | TD | TE | TF | TG | TH | TI | TJ | TK | TL | TM | TN, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>] | [4, ParserResult<TStateE>] | [5, ParserResult<TStateF>] | [6, ParserResult<TStateG>] | [7, ParserResult<TStateH>] | [8, ParserResult<TStateI>] | [9, ParserResult<TStateJ>] | [10, ParserResult<TStateK>] | [11, ParserResult<TStateL>] | [12, ParserResult<TStateM>] | [13, ParserResult<TStateN>]>;
650
+ /**
651
+ * Creates a parser that combines fifteen mutually exclusive parsers into one.
652
+ * The resulting parser will try each of the provided parsers in order,
653
+ * and return the result of the first successful parser.
654
+ * @template MA The mode of the first parser.
655
+ * @template MB The mode of the second parser.
656
+ * @template MC The mode of the third parser.
657
+ * @template MD The mode of the fourth parser.
658
+ * @template ME The mode of the fifth parser.
659
+ * @template MF The mode of the sixth parser.
660
+ * @template MG The mode of the seventh parser.
661
+ * @template MH The mode of the eighth parser.
662
+ * @template MI The mode of the ninth parser.
663
+ * @template MJ The mode of the tenth parser.
664
+ * @template MK The mode of the eleventh parser.
665
+ * @template ML The mode of the twelfth parser.
666
+ * @template MM The mode of the thirteenth parser.
667
+ * @template MN The mode of the fourteenth parser.
668
+ * @template MO The mode of the fifteenth parser.
669
+ * @template TA The type of the value returned by the first parser.
670
+ * @template TB The type of the value returned by the second parser.
671
+ * @template TC The type of the value returned by the third parser.
672
+ * @template TD The type of the value returned by the fourth parser.
673
+ * @template TE The type of the value returned by the fifth parser.
674
+ * @template TF The type of the value returned by the sixth parser.
675
+ * @template TG The type of the value returned by the seventh parser.
676
+ * @template TH The type of the value returned by the eighth parser.
677
+ * @template TI The type of the value returned by the ninth parser.
678
+ * @template TJ The type of the value returned by the tenth parser.
679
+ * @template TK The type of the value returned by the eleventh parser.
680
+ * @template TL The type of the value returned by the twelfth parser.
681
+ * @template TM The type of the value returned by the thirteenth parser.
682
+ * @template TN The type of the value returned by the fourteenth parser.
683
+ * @template TO The type of the value returned by the fifteenth parser.
684
+ * @template TStateA The type of the state used by the first parser.
685
+ * @template TStateB The type of the state used by the second parser.
686
+ * @template TStateC The type of the state used by the third parser.
687
+ * @template TStateD The type of the state used by the fourth parser.
688
+ * @template TStateE The type of the state used by the fifth parser.
689
+ * @template TStateF The type of the state used by the sixth parser.
690
+ * @template TStateG The type of the state used by the seventh parser.
691
+ * @template TStateH The type of the state used by the eighth parser.
692
+ * @template TStateI The type of the state used by the ninth parser.
693
+ * @template TStateJ The type of the state used by the tenth parser.
694
+ * @template TStateK The type of the state used by the eleventh parser.
695
+ * @template TStateL The type of the state used by the twelfth parser.
696
+ * @template TStateM The type of the state used by the thirteenth parser.
697
+ * @template TStateN The type of the state used by the fourteenth parser.
698
+ * @template TStateO The type of the state used by the fifteenth parser.
699
+ * @param a The first {@link Parser} to try.
700
+ * @param b The second {@link Parser} to try.
701
+ * @param c The third {@link Parser} to try.
702
+ * @param d The fourth {@link Parser} to try.
703
+ * @param e The fifth {@link Parser} to try.
704
+ * @param f The sixth {@link Parser} to try.
705
+ * @param g The seventh {@link Parser} to try.
706
+ * @param h The eighth {@link Parser} to try.
707
+ * @param i The ninth {@link Parser} to try.
708
+ * @param j The tenth {@link Parser} to try.
709
+ * @param k The eleventh {@link Parser} to try.
710
+ * @param l The twelfth {@link Parser} to try.
711
+ * @param m The thirteenth {@link Parser} to try.
712
+ * @param n The fourteenth {@link Parser} to try.
713
+ * @param o The fifteenth {@link Parser} to try.
714
+ * @return A {@link Parser} that tries to parse using the provided parsers
715
+ * in order, returning the result of the first successful parser.
716
+ * @since 1.0.0
717
+ */
718
+ declare function or<MA extends Mode, MB extends Mode, MC extends Mode, MD extends Mode, ME extends Mode, MF extends Mode, MG extends Mode, MH extends Mode, MI extends Mode, MJ extends Mode, MK extends Mode, ML extends Mode, MM extends Mode, MN extends Mode, MO extends Mode, TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TK, TL, TM, TN, TO, TStateA, TStateB, TStateC, TStateD, TStateE, TStateF, TStateG, TStateH, TStateI, TStateJ, TStateK, TStateL, TStateM, TStateN, TStateO>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>, d: Parser<MD, TD, TStateD>, e: Parser<ME, TE, TStateE>, f: Parser<MF, TF, TStateF>, g: Parser<MG, TG, TStateG>, h: Parser<MH, TH, TStateH>, i: Parser<MI, TI, TStateI>, j: Parser<MJ, TJ, TStateJ>, k: Parser<MK, TK, TStateK>, l: Parser<ML, TL, TStateL>, m: Parser<MM, TM, TStateM>, n: Parser<MN, TN, TStateN>, o: Parser<MO, TO, TStateO>): Parser<CombineModes<readonly [MA, MB, MC, MD, ME, MF, MG, MH, MI, MJ, MK, ML, MM, MN, MO]>, TA | TB | TC | TD | TE | TF | TG | TH | TI | TJ | TK | TL | TM | TN | TO, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>] | [4, ParserResult<TStateE>] | [5, ParserResult<TStateF>] | [6, ParserResult<TStateG>] | [7, ParserResult<TStateH>] | [8, ParserResult<TStateI>] | [9, ParserResult<TStateJ>] | [10, ParserResult<TStateK>] | [11, ParserResult<TStateL>] | [12, ParserResult<TStateM>] | [13, ParserResult<TStateN>] | [14, ParserResult<TStateO>]>;
401
719
  /**
402
720
  * Creates a parser that combines two mutually exclusive parsers into one,
403
721
  * with custom error message options.
404
- * @template TA The type of the first parser.
405
- * @template TB The type of the second parser.
722
+ * @template MA The mode of the first parser.
723
+ * @template MB The mode of the second parser.
724
+ * @template TA The type of the value returned by the first parser.
725
+ * @template TB The type of the value returned by the second parser.
726
+ * @template TStateA The type of the state used by the first parser.
727
+ * @template TStateB The type of the state used by the second parser.
406
728
  * @param a The first {@link Parser} to try.
407
729
  * @param b The second {@link Parser} to try.
408
730
  * @param options Custom error message options.
409
- * @return A {@link Parser} that tries to parse using the provided parsers.
731
+ * @return A {@link Parser} that tries to parse using the provided parsers
732
+ * in order, returning the result of the first successful parser.
410
733
  * @since 0.5.0
411
734
  */
412
- declare function or<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>>(a: TA, b: TB, options: OrOptions): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>]>, InferValue<TA> | InferValue<TB>, undefined | [number, ParserResult<unknown>]>;
735
+ declare function or<MA extends Mode, MB extends Mode, TA, TB, TStateA, TStateB>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, options: OrOptions): Parser<CombineModes<readonly [MA, MB]>, TA | TB, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>]>;
413
736
  /**
414
737
  * Creates a parser that combines three mutually exclusive parsers into one,
415
738
  * with custom error message options.
416
- * @template TA The type of the first parser.
417
- * @template TB The type of the second parser.
418
- * @template TC The type of the third parser.
739
+ * @template MA The mode of the first parser.
740
+ * @template MB The mode of the second parser.
741
+ * @template MC The mode of the third parser.
742
+ * @template TA The type of the value returned by the first parser.
743
+ * @template TB The type of the value returned by the second parser.
744
+ * @template TC The type of the value returned by the third parser.
745
+ * @template TStateA The type of the state used by the first parser.
746
+ * @template TStateB The type of the state used by the second parser.
747
+ * @template TStateC The type of the state used by the third parser.
419
748
  * @param a The first {@link Parser} to try.
420
749
  * @param b The second {@link Parser} to try.
421
750
  * @param c The third {@link Parser} to try.
422
751
  * @param options Custom error message options.
423
- * @return A {@link Parser} that tries to parse using the provided parsers.
752
+ * @return A {@link Parser} that tries to parse using the provided parsers
753
+ * in order, returning the result of the first successful parser.
424
754
  * @since 0.5.0
425
755
  */
426
- declare function or<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>>(a: TA, b: TB, c: TC, options: OrOptions): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>]>, InferValue<TA> | InferValue<TB> | InferValue<TC>, undefined | [number, ParserResult<unknown>]>;
427
- declare function or(...parsers: Parser<Mode, unknown, unknown>[]): Parser<Mode, unknown, undefined | [number, ParserResult<unknown>]>;
756
+ declare function or<MA extends Mode, MB extends Mode, MC extends Mode, TA, TB, TC, TStateA, TStateB, TStateC>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>, options: OrOptions): Parser<CombineModes<readonly [MA, MB, MC]>, TA | TB | TC, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>]>;
428
757
  /**
429
758
  * Creates a parser that tries each parser in sequence until one succeeds,
430
759
  * with custom error message options.
431
- * @param parser1 The first parser to try.
432
- * @param rest Additional parsers and {@link OrOptions} for error customization.
760
+ * @param rest Parsers to try, followed by {@link OrOptions} for error
761
+ * customization.
433
762
  * @returns A parser that succeeds if any of the input parsers succeed.
434
763
  * @since 0.5.0
435
764
  */
436
- declare function or(parser1: Parser<Mode, unknown, unknown>, ...rest: [...parsers: Parser<Mode, unknown, unknown>[], options: OrOptions]): Parser<Mode, unknown, undefined | [number, ParserResult<unknown>]>;
765
+ declare function or<const TParsers extends readonly Parser<Mode, unknown, unknown>[]>(...rest: [...parsers: TParsers, options: OrTailOptions] & OrArityGuard<TParsers>): Parser<CombineModes<{ readonly [K in keyof TParsers]: ExtractMode<TParsers[K]> }>, InferValue<TParsers[number]>, undefined | [number, ParserResult<unknown>]>;
766
+ /**
767
+ * Creates a parser that tries each parser in sequence until one succeeds.
768
+ * @param parsers Parsers to try in order.
769
+ * @returns A parser that succeeds if any of the input parsers succeed.
770
+ * @since 0.5.0
771
+ */
772
+ declare function or<const TParsers extends readonly Parser<Mode, unknown, unknown>[]>(...parsers: TParsers & OrArityGuard<TParsers>): Parser<CombineModes<{ readonly [K in keyof TParsers]: ExtractMode<TParsers[K]> }>, InferValue<TParsers[number]>, undefined | [number, ParserResult<unknown>]>;
437
773
  /**
438
774
  * Options for customizing error messages in the {@link longestMatch}
439
775
  * combinator.
@@ -446,7 +782,7 @@ interface LongestMatchOptions {
446
782
  errors?: LongestMatchErrorOptions;
447
783
  }
448
784
  /**
449
- * Options for customizing error messages in the {@link longesMatch} parser.
785
+ * Options for customizing error messages in the {@link longestMatch} parser.
450
786
  * @since 0.5.0
451
787
  */
452
788
  interface LongestMatchErrorOptions {
@@ -490,125 +826,88 @@ interface LongestMatchErrorOptions {
490
826
  */
491
827
  suggestions?: (suggestions: readonly string[]) => Message;
492
828
  }
829
+ type LongestMatchParserArity = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15;
830
+ type LongestMatchArityLimitError = {
831
+ readonly __optiqueLongestMatchArityLimit: "longestMatch() requires between 1 and 15 parser arguments. Nest longestMatch() to combine more.";
832
+ };
833
+ type LongestMatchTailOptions = LongestMatchOptions & {
834
+ readonly $valueType?: never;
835
+ };
836
+ type TupleKeys<T extends readonly unknown[]> = Exclude<keyof T, keyof readonly unknown[]>;
837
+ type LongestMatchTupleState<TParsers extends readonly Parser<Mode, unknown, unknown>[]> = { [K in TupleKeys<TParsers>]: TParsers[K] extends Parser<Mode, unknown, infer TState> ? K extends `${infer TIndex extends number}` ? [TIndex, ParserResult<TState>] : never : never }[TupleKeys<TParsers>];
838
+ type LongestMatchState<TParsers extends readonly Parser<Mode, unknown, unknown>[]> = IsTuple<TParsers> extends true ? undefined | LongestMatchTupleState<TParsers> : undefined | [number, ParserResult<unknown>];
839
+ type LongestMatchArityGuard<TParsers extends readonly unknown[]> = IsTuple<TParsers> extends true ? TParsers["length"] extends LongestMatchParserArity ? unknown : LongestMatchArityLimitError : unknown;
493
840
  /**
494
- * Creates a parser that combines two mutually exclusive parsers into one,
495
- * selecting the parser that consumes the most tokens.
496
- * The resulting parser will try both parsers and return the result
497
- * of the parser that consumed more input tokens.
498
- * @template MA The mode of the first parser.
499
- * @template MB The mode of the second parser.
500
- * @template TA The type of the value returned by the first parser.
501
- * @template TB The type of the value returned by the second parser.
502
- * @template TStateA The type of the state used by the first parser.
503
- * @template TStateB The type of the state used by the second parser.
504
- * @param a The first {@link Parser} to try.
505
- * @param b The second {@link Parser} to try.
506
- * @returns A {@link Parser} that tries to parse using both parsers
507
- * and returns the result of the parser that consumed more tokens.
841
+ * Creates a parser that selects the successful branch that consumed
842
+ * the most input tokens.
843
+ *
844
+ * The resulting parser tries every given parser and returns the
845
+ * successful result that consumed more input than the others.
846
+ *
847
+ * @param parsers Parsers to evaluate and compare by consumed input.
848
+ * @returns A parser that yields the best successful branch result.
849
+ * Type inference is precise for tuple calls up to 15 parser arguments.
508
850
  * @since 0.3.0
509
851
  */
510
- declare function longestMatch<MA extends Mode, MB extends Mode, TA, TB, TStateA, TStateB>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>): Parser<CombineModes<readonly [MA, MB]>, TA | TB, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>]>;
852
+ declare function longestMatch<const TParsers extends readonly Parser<"sync", unknown, unknown>[]>(...parsers: TParsers & LongestMatchArityGuard<TParsers>): Parser<"sync", InferValue<TParsers[number]>, LongestMatchState<TParsers>>;
511
853
  /**
512
- * Creates a parser that combines three mutually exclusive parsers into one,
513
- * selecting the parser that consumes the most tokens.
514
- * The resulting parser will try all parsers and return the result
515
- * of the parser that consumed the most input tokens.
516
- * @template MA The mode of the first parser.
517
- * @template MB The mode of the second parser.
518
- * @template MC The mode of the third parser.
519
- * @template TA The type of the value returned by the first parser.
520
- * @template TB The type of the value returned by the second parser.
521
- * @template TC The type of the value returned by the third parser.
522
- * @template TStateA The type of the state used by the first parser.
523
- * @template TStateB The type of the state used by the second parser.
524
- * @template TStateC The type of the state used by the third parser.
525
- * @param a The first {@link Parser} to try.
526
- * @param b The second {@link Parser} to try.
527
- * @param c The third {@link Parser} to try.
528
- * @returns A {@link Parser} that tries to parse using all parsers
529
- * and returns the result of the parser that consumed the most tokens.
530
- * @since 0.3.0
854
+ * Creates a parser that selects the successful branch that consumed
855
+ * the most input tokens, with custom error options.
856
+ *
857
+ * The resulting parser tries every given parser and returns the
858
+ * successful result that consumed more input than the others.
859
+ *
860
+ * @param rest Parsers to compare, followed by error customization options.
861
+ * @returns A parser that yields the best successful branch result.
862
+ * Type inference is precise for tuple calls up to 15 parser arguments.
863
+ * @since 0.5.0
531
864
  */
532
- declare function longestMatch<MA extends Mode, MB extends Mode, MC extends Mode, TA, TB, TC, TStateA, TStateB, TStateC>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>): Parser<CombineModes<readonly [MA, MB, MC]>, TA | TB | TC, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>]>;
865
+ declare function longestMatch<const TParsers extends readonly Parser<"sync", unknown, unknown>[]>(...rest: [...parsers: TParsers, options: LongestMatchTailOptions] & LongestMatchArityGuard<TParsers>): Parser<"sync", InferValue<TParsers[number]>, LongestMatchState<TParsers>>;
533
866
  /**
534
- * Creates a parser that combines four mutually exclusive parsers into one,
535
- * selecting the parser that consumes the most tokens.
536
- * The resulting parser will try all parsers and return the result
537
- * of the parser that consumed the most input tokens.
538
- * @template MA The mode of the first parser.
539
- * @template MB The mode of the second parser.
540
- * @template MC The mode of the third parser.
541
- * @template MD The mode of the fourth parser.
542
- * @template TA The type of the value returned by the first parser.
543
- * @template TB The type of the value returned by the second parser.
544
- * @template TC The type of the value returned by the third parser.
545
- * @template TD The type of the value returned by the fourth parser.
546
- * @template TStateA The type of the state used by the first parser.
547
- * @template TStateB The type of the state used by the second parser.
548
- * @template TStateC The type of the state used by the third parser.
549
- * @template TStateD The type of the state used by the fourth parser.
550
- * @param a The first {@link Parser} to try.
551
- * @param b The second {@link Parser} to try.
552
- * @param c The third {@link Parser} to try.
553
- * @param d The fourth {@link Parser} to try.
554
- * @returns A {@link Parser} that tries to parse using all parsers
555
- * and returns the result of the parser that consumed the most tokens.
556
- * @since 0.3.0
867
+ * Creates a parser that selects the successful branch that consumed
868
+ * the most input tokens, with custom error options.
869
+ *
870
+ * @param rest Parsers to compare, followed by error customization options.
871
+ * @returns A parser that yields the best successful branch result.
872
+ * Type inference is precise for tuple calls up to 15 parser arguments.
873
+ * @since 0.5.0
557
874
  */
558
- declare function longestMatch<MA extends Mode, MB extends Mode, MC extends Mode, MD extends Mode, TA, TB, TC, TD, TStateA, TStateB, TStateC, TStateD>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>, d: Parser<MD, TD, TStateD>): Parser<CombineModes<readonly [MA, MB, MC, MD]>, TA | TB | TC | TD, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>]>;
875
+ declare function longestMatch<const TParsers extends readonly Parser<Mode, unknown, unknown>[]>(...rest: [...parsers: TParsers, options: LongestMatchTailOptions] & LongestMatchArityGuard<TParsers>): Parser<CombineModes<{ readonly [K in keyof TParsers]: ExtractMode<TParsers[K]> }>, InferValue<TParsers[number]>, LongestMatchState<TParsers>>;
559
876
  /**
560
- * Creates a parser that combines five mutually exclusive parsers into one,
561
- * selecting the parser that consumes the most tokens.
562
- * The resulting parser will try all parsers and return the result
563
- * of the parser that consumed the most input tokens.
564
- * @template MA The mode of the first parser.
565
- * @template MB The mode of the second parser.
566
- * @template MC The mode of the third parser.
567
- * @template MD The mode of the fourth parser.
568
- * @template ME The mode of the fifth parser.
569
- * @template TA The type of the value returned by the first parser.
570
- * @template TB The type of the value returned by the second parser.
571
- * @template TC The type of the value returned by the third parser.
572
- * @template TD The type of the value returned by the fourth parser.
573
- * @template TE The type of the value returned by the fifth parser.
574
- * @template TStateA The type of the state used by the first parser.
575
- * @template TStateB The type of the state used by the second parser.
576
- * @template TStateC The type of the state used by the third parser.
577
- * @template TStateD The type of the state used by the fourth parser.
578
- * @template TStateE The type of the state used by the fifth parser.
579
- * @param a The first {@link Parser} to try.
580
- * @param b The second {@link Parser} to try.
581
- * @param c The third {@link Parser} to try.
582
- * @param d The fourth {@link Parser} to try.
583
- * @param e The fifth {@link Parser} to try.
584
- * @returns A {@link Parser} that tries to parse using all parsers
585
- * and returns the result of the parser that consumed the most tokens.
877
+ * Creates a parser that selects the successful branch that consumed
878
+ * the most input tokens.
879
+ *
880
+ * The resulting parser tries every given parser and returns the
881
+ * successful result that consumed more input than the others.
882
+ *
883
+ * @param parsers Parsers to evaluate and compare by consumed input.
884
+ * @returns A parser that yields the best successful branch result.
885
+ * Type inference is precise for tuple calls up to 15 parser arguments.
586
886
  * @since 0.3.0
587
887
  */
588
- declare function longestMatch<MA extends Mode, MB extends Mode, MC extends Mode, MD extends Mode, ME extends Mode, TA, TB, TC, TD, TE, TStateA, TStateB, TStateC, TStateD, TStateE>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>, d: Parser<MD, TD, TStateD>, e: Parser<ME, TE, TStateE>): Parser<CombineModes<readonly [MA, MB, MC, MD, ME]>, TA | TB | TC | TD | TE, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>] | [4, ParserResult<TStateE>]>;
589
- /**
590
- * Creates a parser that combines two mutually exclusive parsers into one,
591
- * with custom error message options.
592
- * @since 0.5.0
593
- */
594
- declare function longestMatch<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>>(a: TA, b: TB, options: LongestMatchOptions): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>]>, InferValue<TA> | InferValue<TB>, undefined | [number, ParserResult<unknown>]>;
888
+ declare function longestMatch<const TParsers extends readonly Parser<Mode, unknown, unknown>[]>(...parsers: TParsers & LongestMatchArityGuard<TParsers>): Parser<CombineModes<{ readonly [K in keyof TParsers]: ExtractMode<TParsers[K]> }>, InferValue<TParsers[number]>, LongestMatchState<TParsers>>;
595
889
  /**
596
- * Creates a parser that combines three mutually exclusive parsers into one,
597
- * with custom error message options.
598
- * @since 0.5.0
890
+ * Creates a parser that selects the successful branch that consumed
891
+ * the most input tokens from a homogeneous parser list.
892
+ *
893
+ * This overload is intended for spread arrays whose element types are
894
+ * homogeneous enough that callers only need the shared value type.
895
+ *
896
+ * @param parsers Parsers to evaluate and compare by consumed input.
897
+ * @returns A parser that preserves the shared parser mode and value type.
898
+ * @since 1.0.0
599
899
  */
600
- declare function longestMatch<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>>(a: TA, b: TB, c: TC, options: LongestMatchOptions): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>]>, InferValue<TA> | InferValue<TB> | InferValue<TC>, undefined | [number, ParserResult<unknown>]>;
601
- declare function longestMatch(...parsers: Parser<Mode, unknown, unknown>[]): Parser<Mode, unknown, undefined | [number, ParserResult<unknown>]>;
900
+ declare function longestMatch<M extends Mode, TValue, TState, const TParsers extends readonly Parser<M, TValue, TState>[]>(...parsers: TParsers & LongestMatchArityGuard<TParsers>): Parser<M, TValue, unknown>;
602
901
  /**
603
- * Creates a parser that tries all parsers and selects the one that consumes
604
- * the most input, with custom error message options.
605
- * @param parser1 The first parser to try.
606
- * @param rest Additional parsers and {@link LongestMatchOptions} for error customization.
607
- * @returns A parser that succeeds with the result from the parser that
608
- * consumed the most input.
609
- * @since 0.5.0
902
+ * Creates a parser that selects the successful branch that consumed
903
+ * the most input tokens from a homogeneous parser list, with custom
904
+ * error options.
905
+ *
906
+ * @param rest Parsers to compare, followed by error customization options.
907
+ * @returns A parser that preserves the shared parser mode and value type.
908
+ * @since 1.0.0
610
909
  */
611
- declare function longestMatch(parser1: Parser<Mode, unknown, unknown>, ...rest: [...parsers: Parser<Mode, unknown, unknown>[], options: LongestMatchOptions]): Parser<Mode, unknown, undefined | [number, ParserResult<unknown>]>;
910
+ declare function longestMatch<M extends Mode, TValue, TState, const TParsers extends readonly Parser<M, TValue, TState>[]>(...rest: [...parsers: TParsers, options: LongestMatchTailOptions] & LongestMatchArityGuard<TParsers>): Parser<M, TValue, unknown>;
612
911
  /**
613
912
  * Options for the {@link object} parser.
614
913
  * @since 0.5.0
@@ -626,6 +925,11 @@ interface ObjectOptions {
626
925
  * @since 0.7.0
627
926
  */
628
927
  readonly allowDuplicates?: boolean;
928
+ /**
929
+ * Controls visibility of all terms emitted by this object parser.
930
+ * @since 1.0.0
931
+ */
932
+ readonly hidden?: HiddenVisibility;
629
933
  }
630
934
  /**
631
935
  * Options for customizing error messages in the {@link object} parser.
@@ -799,465 +1103,96 @@ interface MergeOptions {
799
1103
  * @since 0.7.0
800
1104
  */
801
1105
  readonly allowDuplicates?: boolean;
1106
+ /**
1107
+ * Controls visibility of all terms emitted by this merged parser.
1108
+ * @since 1.0.0
1109
+ */
1110
+ readonly hidden?: HiddenVisibility;
802
1111
  }
803
- /**
804
- * Merges multiple {@link object} parsers into a single {@link object} parser.
805
- * It is useful for combining multiple {@link object} parsers so that
806
- * the unified parser produces a single object containing all the values
807
- * from the individual parsers while separating the fields into multiple
808
- * groups.
809
- * @template TA The type of the first parser.
810
- * @template TB The type of the second parser.
811
- * @param a The first {@link object} parser to merge.
812
- * @param b The second {@link object} parser to merge.
813
- * @return A new {@link object} parser that combines the values and states
814
- * of the two parsers into a single object.
815
- */
816
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>>(a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB>, Record<string | symbol, unknown>>;
817
- /**
818
- * Merges multiple {@link object} parsers into a single {@link object} parser.
819
- * It is useful for combining multiple {@link object} parsers so that
820
- * the unified parser produces a single object containing all the values
821
- * from the individual parsers while separating the fields into multiple
822
- * groups.
823
- * @template TA The type of the first parser.
824
- * @template TB The type of the second parser.
825
- * @param a The first {@link object} parser to merge.
826
- * @param b The second {@link object} parser to merge.
827
- * @param options Optional configuration for the merge parser.
828
- * @return A new {@link object} parser that combines the values and states
829
- * of the two parsers into a single object.
830
- */
831
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>>(a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, options: MergeOptions): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB>, Record<string | symbol, unknown>>;
832
- /**
833
- * Merges multiple {@link object} parsers into a single {@link object} parser
834
- * with a label for documentation and help text organization.
835
- * It is useful for combining multiple {@link object} parsers so that
836
- * the unified parser produces a single object containing all the values
837
- * from the individual parsers while separating the fields into multiple
838
- * groups.
839
- * @template TA The type of the first parser.
840
- * @template TB The type of the second parser.
841
- * @param label A descriptive label for this merged group, used for
842
- * documentation and help messages.
843
- * @param a The first {@link object} parser to merge.
844
- * @param b The second {@link object} parser to merge.
845
- * @return A new {@link object} parser that combines the values and states
846
- * of the two parsers into a single object.
847
- */
848
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>>(label: string, a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB>, Record<string | symbol, unknown>>;
849
- /**
850
- * Merges multiple {@link object} parsers into a single {@link object} parser.
851
- * It is useful for combining multiple {@link object} parsers so that
852
- * the unified parser produces a single object containing all the values
853
- * from the individual parsers while separating the fields into multiple
854
- * groups.
855
- * @template TA The type of the first parser.
856
- * @template TB The type of the second parser.
857
- * @template TC The type of the third parser.
858
- * @param a The first {@link object} parser to merge.
859
- * @param b The second {@link object} parser to merge.
860
- * @param c The third {@link object} parser to merge.
861
- * @return A new {@link object} parser that combines the values and states
862
- * of the two parsers into a single object.
863
- */
864
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>>(a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC>, Record<string | symbol, unknown>>;
865
- /**
866
- * Merges multiple {@link object} parsers into a single {@link object} parser
867
- * with a label for documentation and help text organization.
868
- * It is useful for combining multiple {@link object} parsers so that
869
- * the unified parser produces a single object containing all the values
870
- * from the individual parsers while separating the fields into multiple
871
- * groups.
872
- * @template TA The type of the first parser.
873
- * @template TB The type of the second parser.
874
- * @template TC The type of the third parser.
875
- * @param label A descriptive label for this merged group, used for
876
- * documentation and help messages.
877
- * @param a The first {@link object} parser to merge.
878
- * @param b The second {@link object} parser to merge.
879
- * @param c The third {@link object} parser to merge.
880
- * @return A new {@link object} parser that combines the values and states
881
- * of the two parsers into a single object.
882
- */
883
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>>(label: string, a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC>, Record<string | symbol, unknown>>;
884
- /**
885
- * Merges multiple {@link object} parsers into a single {@link object} parser.
886
- * It is useful for combining multiple {@link object} parsers so that
887
- * the unified parser produces a single object containing all the values
888
- * from the individual parsers while separating the fields into multiple
889
- * groups.
890
- * @template TA The type of the first parser.
891
- * @template TB The type of the second parser.
892
- * @template TC The type of the third parser.
893
- * @template TD The type of the fourth parser.
894
- * @param a The first {@link object} parser to merge.
895
- * @param b The second {@link object} parser to merge.
896
- * @param c The third {@link object} parser to merge.
897
- * @param d The fourth {@link object} parser to merge.
898
- * @return A new {@link object} parser that combines the values and states
899
- * of the two parsers into a single object.
900
- */
901
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, unknown, unknown>>(a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC, d: ExtractObjectTypes<TD> extends never ? never : TD): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>, ExtractMode<TD>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD>, Record<string | symbol, unknown>>;
902
- /**
903
- * Merges multiple {@link object} parsers into a single {@link object} parser
904
- * with a label for documentation and help text organization.
905
- * It is useful for combining multiple {@link object} parsers so that
906
- * the unified parser produces a single object containing all the values
907
- * from the individual parsers while separating the fields into multiple
908
- * groups.
909
- * @template TA The type of the first parser.
910
- * @template TB The type of the second parser.
911
- * @template TC The type of the third parser.
912
- * @template TD The type of the fourth parser.
913
- * @param label A descriptive label for this merged group, used for
914
- * documentation and help messages.
915
- * @param a The first {@link object} parser to merge.
916
- * @param b The second {@link object} parser to merge.
917
- * @param c The third {@link object} parser to merge.
918
- * @param d The fourth {@link object} parser to merge.
919
- * @return A new {@link object} parser that combines the values and states
920
- * of the two parsers into a single object.
921
- */
922
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, unknown, unknown>>(label: string, a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC, d: ExtractObjectTypes<TD> extends never ? never : TD): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>, ExtractMode<TD>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD>, Record<string | symbol, unknown>>;
923
- /**
924
- * Merges multiple {@link object} parsers into a single {@link object} parser.
925
- * It is useful for combining multiple {@link object} parsers so that
926
- * the unified parser produces a single object containing all the values
927
- * from the individual parsers while separating the fields into multiple
928
- * groups.
929
- * @template TA The type of the first parser.
930
- * @template TB The type of the second parser.
931
- * @template TC The type of the third parser.
932
- * @template TD The type of the fourth parser.
933
- * @template TE The type of the fifth parser.
934
- * @param a The first {@link object} parser to merge.
935
- * @param b The second {@link object} parser to merge.
936
- * @param c The third {@link object} parser to merge.
937
- * @param d The fourth {@link object} parser to merge.
938
- * @param e The fifth {@link object} parser to merge.
939
- * @return A new {@link object} parser that combines the values and states
940
- * of the two parsers into a single object.
941
- */
942
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, unknown, unknown>, TE extends Parser<Mode, unknown, unknown>>(a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC, d: ExtractObjectTypes<TD> extends never ? never : TD, e: ExtractObjectTypes<TE> extends never ? never : TE): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>, ExtractMode<TD>, ExtractMode<TE>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE>, Record<string | symbol, unknown>>;
943
- /**
944
- * Merges multiple {@link object} parsers into a single {@link object} parser
945
- * with a label for documentation and help text organization.
946
- * It is useful for combining multiple {@link object} parsers so that
947
- * the unified parser produces a single object containing all the values
948
- * from the individual parsers while separating the fields into multiple
949
- * groups.
950
- * @template TA The type of the first parser.
951
- * @template TB The type of the second parser.
952
- * @template TC The type of the third parser.
953
- * @template TD The type of the fourth parser.
954
- * @template TE The type of the fifth parser.
955
- * @param label A descriptive label for this merged group, used for
956
- * documentation and help messages.
957
- * @param a The first {@link object} parser to merge.
958
- * @param b The second {@link object} parser to merge.
959
- * @param c The third {@link object} parser to merge.
960
- * @param d The fourth {@link object} parser to merge.
961
- * @param e The fifth {@link object} parser to merge.
962
- * @return A new {@link object} parser that combines the values and states
963
- * of the two parsers into a single object.
964
- */
965
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, unknown, unknown>, TE extends Parser<Mode, unknown, unknown>>(label: string, a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC, d: ExtractObjectTypes<TD> extends never ? never : TD, e: ExtractObjectTypes<TE> extends never ? never : TE): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>, ExtractMode<TD>, ExtractMode<TE>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE>, Record<string | symbol, unknown>>;
966
- /**
967
- * Merges multiple {@link object} parsers into a single {@link object} parser.
968
- * It is useful for combining multiple {@link object} parsers so that
969
- * the unified parser produces a single object containing all the values
970
- * from the individual parsers while separating the fields into multiple
971
- * groups.
972
- * @template TA The type of the first parser.
973
- * @template TB The type of the second parser.
974
- * @template TC The type of the third parser.
975
- * @template TD The type of the fourth parser.
976
- * @template TE The type of the fifth parser.
977
- * @template TF The type of the sixth parser.
978
- * @param a The first {@link object} parser to merge.
979
- * @param b The second {@link object} parser to merge.
980
- * @param c The third {@link object} parser to merge.
981
- * @param d The fourth {@link object} parser to merge.
982
- * @param e The fifth {@link object} parser to merge.
983
- * @param f The sixth {@link object} parser to merge.
984
- * @return A new {@link object} parser that combines the values and states
985
- * of the parsers into a single object.
986
- * @since 0.4.0
987
- */
988
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, unknown, unknown>, TE extends Parser<Mode, unknown, unknown>, TF extends Parser<Mode, unknown, unknown>>(a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC, d: ExtractObjectTypes<TD> extends never ? never : TD, e: ExtractObjectTypes<TE> extends never ? never : TE, f: ExtractObjectTypes<TF> extends never ? never : TF): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>, ExtractMode<TD>, ExtractMode<TE>, ExtractMode<TF>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE> & ExtractObjectTypes<TF>, Record<string | symbol, unknown>>;
989
- /**
990
- * Merges multiple {@link object} parsers into a single {@link object} parser
991
- * with a label for documentation and help text organization.
992
- * It is useful for combining multiple {@link object} parsers so that
993
- * the unified parser produces a single object containing all the values
994
- * from the individual parsers while separating the fields into multiple
995
- * groups.
996
- * @template TA The type of the first parser.
997
- * @template TB The type of the second parser.
998
- * @template TC The type of the third parser.
999
- * @template TD The type of the fourth parser.
1000
- * @template TE The type of the fifth parser.
1001
- * @template TF The type of the sixth parser.
1002
- * @param label A descriptive label for this merged group, used for
1003
- * documentation and help messages.
1004
- * @param a The first {@link object} parser to merge.
1005
- * @param b The second {@link object} parser to merge.
1006
- * @param c The third {@link object} parser to merge.
1007
- * @param d The fourth {@link object} parser to merge.
1008
- * @param e The fifth {@link object} parser to merge.
1009
- * @param f The sixth {@link object} parser to merge.
1010
- * @return A new {@link object} parser that combines the values and states
1011
- * of the parsers into a single object.
1012
- * @since 0.4.0
1013
- */
1014
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, unknown, unknown>, TE extends Parser<Mode, unknown, unknown>, TF extends Parser<Mode, unknown, unknown>>(label: string, a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC, d: ExtractObjectTypes<TD> extends never ? never : TD, e: ExtractObjectTypes<TE> extends never ? never : TE, f: ExtractObjectTypes<TF> extends never ? never : TF): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>, ExtractMode<TD>, ExtractMode<TE>, ExtractMode<TF>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE> & ExtractObjectTypes<TF>, Record<string | symbol, unknown>>;
1015
- /**
1016
- * Merges multiple {@link object} parsers into a single {@link object} parser.
1017
- * It is useful for combining multiple {@link object} parsers so that
1018
- * the unified parser produces a single object containing all the values
1019
- * from the individual parsers while separating the fields into multiple
1020
- * groups.
1021
- * @template TA The type of the first parser.
1022
- * @template TB The type of the second parser.
1023
- * @template TC The type of the third parser.
1024
- * @template TD The type of the fourth parser.
1025
- * @template TE The type of the fifth parser.
1026
- * @template TF The type of the sixth parser.
1027
- * @template TG The type of the seventh parser.
1028
- * @param a The first {@link object} parser to merge.
1029
- * @param b The second {@link object} parser to merge.
1030
- * @param c The third {@link object} parser to merge.
1031
- * @param d The fourth {@link object} parser to merge.
1032
- * @param e The fifth {@link object} parser to merge.
1033
- * @param f The sixth {@link object} parser to merge.
1034
- * @param g The seventh {@link object} parser to merge.
1035
- * @return A new {@link object} parser that combines the values and states
1036
- * of the parsers into a single object.
1037
- * @since 0.4.0
1038
- */
1039
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, unknown, unknown>, TE extends Parser<Mode, unknown, unknown>, TF extends Parser<Mode, unknown, unknown>, TG extends Parser<Mode, unknown, unknown>>(a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC, d: ExtractObjectTypes<TD> extends never ? never : TD, e: ExtractObjectTypes<TE> extends never ? never : TE, f: ExtractObjectTypes<TF> extends never ? never : TF, g: ExtractObjectTypes<TG> extends never ? never : TG): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>, ExtractMode<TD>, ExtractMode<TE>, ExtractMode<TF>, ExtractMode<TG>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE> & ExtractObjectTypes<TF> & ExtractObjectTypes<TG>, Record<string | symbol, unknown>>;
1040
- /**
1041
- * Merges multiple {@link object} parsers into a single {@link object} parser
1042
- * with a label for documentation and help text organization.
1043
- * It is useful for combining multiple {@link object} parsers so that
1044
- * the unified parser produces a single object containing all the values
1045
- * from the individual parsers while separating the fields into multiple
1046
- * groups.
1047
- * @template TA The type of the first parser.
1048
- * @template TB The type of the second parser.
1049
- * @template TC The type of the third parser.
1050
- * @template TD The type of the fourth parser.
1051
- * @template TE The type of the fifth parser.
1052
- * @template TF The type of the sixth parser.
1053
- * @template TG The type of the seventh parser.
1054
- * @param label A descriptive label for this merged group, used for
1055
- * documentation and help messages.
1056
- * @param a The first {@link object} parser to merge.
1057
- * @param b The second {@link object} parser to merge.
1058
- * @param c The third {@link object} parser to merge.
1059
- * @param d The fourth {@link object} parser to merge.
1060
- * @param e The fifth {@link object} parser to merge.
1061
- * @param f The sixth {@link object} parser to merge.
1062
- * @param g The seventh {@link object} parser to merge.
1063
- * @return A new {@link object} parser that combines the values and states
1064
- * of the parsers into a single object.
1065
- * @since 0.4.0
1066
- */
1067
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, unknown, unknown>, TE extends Parser<Mode, unknown, unknown>, TF extends Parser<Mode, unknown, unknown>, TG extends Parser<Mode, unknown, unknown>>(label: string, a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC, d: ExtractObjectTypes<TD> extends never ? never : TD, e: ExtractObjectTypes<TE> extends never ? never : TE, f: ExtractObjectTypes<TF> extends never ? never : TF, g: ExtractObjectTypes<TG> extends never ? never : TG): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>, ExtractMode<TD>, ExtractMode<TE>, ExtractMode<TF>, ExtractMode<TG>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE> & ExtractObjectTypes<TF> & ExtractObjectTypes<TG>, Record<string | symbol, unknown>>;
1068
- /**
1069
- * Merges multiple {@link object} parsers into a single {@link object} parser.
1070
- * It is useful for combining multiple {@link object} parsers so that
1071
- * the unified parser produces a single object containing all the values
1072
- * from the individual parsers while separating the fields into multiple
1073
- * groups.
1074
- * @template TA The type of the first parser.
1075
- * @template TB The type of the second parser.
1076
- * @template TC The type of the third parser.
1077
- * @template TD The type of the fourth parser.
1078
- * @template TE The type of the fifth parser.
1079
- * @template TF The type of the sixth parser.
1080
- * @template TG The type of the seventh parser.
1081
- * @template TH The type of the eighth parser.
1082
- * @param a The first {@link object} parser to merge.
1083
- * @param b The second {@link object} parser to merge.
1084
- * @param c The third {@link object} parser to merge.
1085
- * @param d The fourth {@link object} parser to merge.
1086
- * @param e The fifth {@link object} parser to merge.
1087
- * @param f The sixth {@link object} parser to merge.
1088
- * @param g The seventh {@link object} parser to merge.
1089
- * @param h The eighth {@link object} parser to merge.
1090
- * @return A new {@link object} parser that combines the values and states
1091
- * of the parsers into a single object.
1092
- * @since 0.4.0
1093
- */
1094
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, unknown, unknown>, TE extends Parser<Mode, unknown, unknown>, TF extends Parser<Mode, unknown, unknown>, TG extends Parser<Mode, unknown, unknown>, TH extends Parser<Mode, unknown, unknown>>(a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC, d: ExtractObjectTypes<TD> extends never ? never : TD, e: ExtractObjectTypes<TE> extends never ? never : TE, f: ExtractObjectTypes<TF> extends never ? never : TF, g: ExtractObjectTypes<TG> extends never ? never : TG, h: ExtractObjectTypes<TH> extends never ? never : TH): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>, ExtractMode<TD>, ExtractMode<TE>, ExtractMode<TF>, ExtractMode<TG>, ExtractMode<TH>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE> & ExtractObjectTypes<TF> & ExtractObjectTypes<TG> & ExtractObjectTypes<TH>, Record<string | symbol, unknown>>;
1095
- /**
1096
- * Merges multiple {@link object} parsers into a single {@link object} parser
1097
- * with a label for documentation and help text organization.
1098
- * It is useful for combining multiple {@link object} parsers so that
1099
- * the unified parser produces a single object containing all the values
1100
- * from the individual parsers while separating the fields into multiple
1101
- * groups.
1102
- * @template TA The type of the first parser.
1103
- * @template TB The type of the second parser.
1104
- * @template TC The type of the third parser.
1105
- * @template TD The type of the fourth parser.
1106
- * @template TE The type of the fifth parser.
1107
- * @template TF The type of the sixth parser.
1108
- * @template TG The type of the seventh parser.
1109
- * @template TH The type of the eighth parser.
1110
- * @param label A descriptive label for this merged group, used for
1111
- * documentation and help messages.
1112
- * @param a The first {@link object} parser to merge.
1113
- * @param b The second {@link object} parser to merge.
1114
- * @param c The third {@link object} parser to merge.
1115
- * @param d The fourth {@link object} parser to merge.
1116
- * @param e The fifth {@link object} parser to merge.
1117
- * @param f The sixth {@link object} parser to merge.
1118
- * @param g The seventh {@link object} parser to merge.
1119
- * @param h The eighth {@link object} parser to merge.
1120
- * @return A new {@link object} parser that combines the values and states
1121
- * of the parsers into a single object.
1122
- * @since 0.4.0
1123
- */
1124
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, unknown, unknown>, TE extends Parser<Mode, unknown, unknown>, TF extends Parser<Mode, unknown, unknown>, TG extends Parser<Mode, unknown, unknown>, TH extends Parser<Mode, unknown, unknown>>(label: string, a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC, d: ExtractObjectTypes<TD> extends never ? never : TD, e: ExtractObjectTypes<TE> extends never ? never : TE, f: ExtractObjectTypes<TF> extends never ? never : TF, g: ExtractObjectTypes<TG> extends never ? never : TG, h: ExtractObjectTypes<TH> extends never ? never : TH): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>, ExtractMode<TD>, ExtractMode<TE>, ExtractMode<TF>, ExtractMode<TG>, ExtractMode<TH>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE> & ExtractObjectTypes<TF> & ExtractObjectTypes<TG> & ExtractObjectTypes<TH>, Record<string | symbol, unknown>>;
1125
- /**
1126
- * Merges multiple {@link object} parsers into a single {@link object} parser.
1127
- * It is useful for combining multiple {@link object} parsers so that
1128
- * the unified parser produces a single object containing all the values
1129
- * from the individual parsers while separating the fields into multiple
1130
- * groups.
1131
- * @template TA The type of the first parser.
1132
- * @template TB The type of the second parser.
1133
- * @template TC The type of the third parser.
1134
- * @template TD The type of the fourth parser.
1135
- * @template TE The type of the fifth parser.
1136
- * @template TF The type of the sixth parser.
1137
- * @template TG The type of the seventh parser.
1138
- * @template TH The type of the eighth parser.
1139
- * @template TI The type of the ninth parser.
1140
- * @param a The first {@link object} parser to merge.
1141
- * @param b The second {@link object} parser to merge.
1142
- * @param c The third {@link object} parser to merge.
1143
- * @param d The fourth {@link object} parser to merge.
1144
- * @param e The fifth {@link object} parser to merge.
1145
- * @param f The sixth {@link object} parser to merge.
1146
- * @param g The seventh {@link object} parser to merge.
1147
- * @param h The eighth {@link object} parser to merge.
1148
- * @param i The ninth {@link object} parser to merge.
1149
- * @return A new {@link object} parser that combines the values and states
1150
- * of the parsers into a single object.
1151
- * @since 0.4.0
1112
+ type MergeParserArity = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15;
1113
+ type MergeArityLimitError = {
1114
+ readonly __optiqueMergeArityLimit: "merge() requires between 1 and 15 parser arguments. Nest merge() to combine more.";
1115
+ };
1116
+ type MergeTailOptions = MergeOptions & {
1117
+ readonly $valueType?: never;
1118
+ };
1119
+ type MergeArityGuard<TParsers extends readonly unknown[]> = IsTuple<TParsers> extends true ? TParsers["length"] extends MergeParserArity ? unknown : MergeArityLimitError : unknown;
1120
+ type MergeParsers = readonly Parser<Mode, unknown, unknown>[];
1121
+ type EnsureMergeParsers<TParsers extends MergeParsers> = { readonly [K in keyof TParsers]: ExtractObjectTypes<TParsers[K]> extends never ? never : TParsers[K] };
1122
+ type IntersectMergeValues<TParsers extends MergeParsers> = TParsers extends readonly [infer THead extends Parser<Mode, unknown, unknown>, ...infer TRest extends MergeParsers] ? ExtractObjectTypes<THead> & IntersectMergeValues<TRest> : unknown;
1123
+ type MergeValues<TParsers extends MergeParsers> = IsTuple<TParsers> extends true ? IntersectMergeValues<TParsers> : Record<string | symbol, unknown>;
1124
+ type MergeReturnType<TParsers extends MergeParsers> = Parser<CombineModes<{ readonly [K in keyof TParsers]: ExtractMode<TParsers[K]> }>, MergeValues<TParsers>, Record<string | symbol, unknown>>;
1125
+ /**
1126
+ * Merges multiple object-like parsers into one parser, with options.
1127
+ *
1128
+ * This is useful for combining separate object parsers into one
1129
+ * unified parser while keeping fields grouped by parser boundaries.
1130
+ *
1131
+ * @param rest Parsers to merge, followed by merge options.
1132
+ * @returns A parser that merges parsed object fields from all parsers.
1133
+ * Type inference is precise for tuple calls up to 15 parser arguments.
1134
+ * @since 0.7.0
1152
1135
  */
1153
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, unknown, unknown>, TE extends Parser<Mode, unknown, unknown>, TF extends Parser<Mode, unknown, unknown>, TG extends Parser<Mode, unknown, unknown>, TH extends Parser<Mode, unknown, unknown>, TI extends Parser<Mode, unknown, unknown>>(a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC, d: ExtractObjectTypes<TD> extends never ? never : TD, e: ExtractObjectTypes<TE> extends never ? never : TE, f: ExtractObjectTypes<TF> extends never ? never : TF, g: ExtractObjectTypes<TG> extends never ? never : TG, h: ExtractObjectTypes<TH> extends never ? never : TH, i: ExtractObjectTypes<TI> extends never ? never : TI): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>, ExtractMode<TD>, ExtractMode<TE>, ExtractMode<TF>, ExtractMode<TG>, ExtractMode<TH>, ExtractMode<TI>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE> & ExtractObjectTypes<TF> & ExtractObjectTypes<TG> & ExtractObjectTypes<TH> & ExtractObjectTypes<TI>, Record<string | symbol, unknown>>;
1136
+ declare function merge<const TParsers extends MergeParsers>(...rest: [...parsers: EnsureMergeParsers<TParsers>, options: MergeTailOptions] & MergeArityGuard<TParsers>): MergeReturnType<TParsers>;
1154
1137
  /**
1155
- * Merges multiple {@link object} parsers into a single {@link object} parser
1156
- * with a label for documentation and help text organization.
1157
- * It is useful for combining multiple {@link object} parsers so that
1158
- * the unified parser produces a single object containing all the values
1159
- * from the individual parsers while separating the fields into multiple
1160
- * groups.
1161
- * @template TA The type of the first parser.
1162
- * @template TB The type of the second parser.
1163
- * @template TC The type of the third parser.
1164
- * @template TD The type of the fourth parser.
1165
- * @template TE The type of the fifth parser.
1166
- * @template TF The type of the sixth parser.
1167
- * @template TG The type of the seventh parser.
1168
- * @template TH The type of the eighth parser.
1169
- * @template TI The type of the ninth parser.
1170
- * @param label A descriptive label for this merged group, used for
1171
- * documentation and help messages.
1172
- * @param a The first {@link object} parser to merge.
1173
- * @param b The second {@link object} parser to merge.
1174
- * @param c The third {@link object} parser to merge.
1175
- * @param d The fourth {@link object} parser to merge.
1176
- * @param e The fifth {@link object} parser to merge.
1177
- * @param f The sixth {@link object} parser to merge.
1178
- * @param g The seventh {@link object} parser to merge.
1179
- * @param h The eighth {@link object} parser to merge.
1180
- * @param i The ninth {@link object} parser to merge.
1181
- * @return A new {@link object} parser that combines the values and states
1182
- * of the parsers into a single object.
1138
+ * Merges multiple object-like parsers into one labeled parser.
1139
+ *
1140
+ * This is useful for combining separate object parsers into one
1141
+ * unified parser while keeping fields grouped by parser boundaries.
1142
+ *
1143
+ * @param label Label used in documentation output.
1144
+ * @param parsers Parsers to merge in declaration order.
1145
+ * @returns A parser that merges parsed object fields from all parsers.
1146
+ * Type inference is precise for tuple calls up to 15 parser arguments.
1183
1147
  * @since 0.4.0
1184
1148
  */
1185
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, unknown, unknown>, TE extends Parser<Mode, unknown, unknown>, TF extends Parser<Mode, unknown, unknown>, TG extends Parser<Mode, unknown, unknown>, TH extends Parser<Mode, unknown, unknown>, TI extends Parser<Mode, unknown, unknown>>(label: string, a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC, d: ExtractObjectTypes<TD> extends never ? never : TD, e: ExtractObjectTypes<TE> extends never ? never : TE, f: ExtractObjectTypes<TF> extends never ? never : TF, g: ExtractObjectTypes<TG> extends never ? never : TG, h: ExtractObjectTypes<TH> extends never ? never : TH, i: ExtractObjectTypes<TI> extends never ? never : TI): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>, ExtractMode<TD>, ExtractMode<TE>, ExtractMode<TF>, ExtractMode<TG>, ExtractMode<TH>, ExtractMode<TI>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE> & ExtractObjectTypes<TF> & ExtractObjectTypes<TG> & ExtractObjectTypes<TH> & ExtractObjectTypes<TI>, Record<string | symbol, unknown>>;
1149
+ declare function merge<const TParsers extends MergeParsers>(label: string, ...parsers: EnsureMergeParsers<TParsers> & MergeArityGuard<TParsers>): MergeReturnType<TParsers>;
1186
1150
  /**
1187
- * Merges multiple {@link object} parsers into a single {@link object} parser.
1188
- * It is useful for combining multiple {@link object} parsers so that
1189
- * the unified parser produces a single object containing all the values
1190
- * from the individual parsers while separating the fields into multiple
1191
- * groups.
1192
- * @template TA The type of the first parser.
1193
- * @template TB The type of the second parser.
1194
- * @template TC The type of the third parser.
1195
- * @template TD The type of the fourth parser.
1196
- * @template TE The type of the fifth parser.
1197
- * @template TF The type of the sixth parser.
1198
- * @template TG The type of the seventh parser.
1199
- * @template TH The type of the eighth parser.
1200
- * @template TI The type of the ninth parser.
1201
- * @template TJ The type of the tenth parser.
1202
- * @param a The first {@link object} parser to merge.
1203
- * @param b The second {@link object} parser to merge.
1204
- * @param c The third {@link object} parser to merge.
1205
- * @param d The fourth {@link object} parser to merge.
1206
- * @param e The fifth {@link object} parser to merge.
1207
- * @param f The sixth {@link object} parser to merge.
1208
- * @param g The seventh {@link object} parser to merge.
1209
- * @param h The eighth {@link object} parser to merge.
1210
- * @param i The ninth {@link object} parser to merge.
1211
- * @param j The tenth {@link object} parser to merge.
1212
- * @return A new {@link object} parser that combines the values and states
1213
- * of the parsers into a single object.
1214
- * @since 0.4.0
1151
+ * Merges multiple object-like parsers into one labeled parser, with options.
1152
+ *
1153
+ * This is useful for combining separate object parsers into one
1154
+ * unified parser while keeping fields grouped by parser boundaries.
1155
+ *
1156
+ * @param label Label used in documentation output.
1157
+ * @param rest Parsers to merge, followed by merge options.
1158
+ * @returns A parser that merges parsed object fields from all parsers.
1159
+ * Type inference is precise for tuple calls up to 15 parser arguments.
1160
+ * @since 0.7.0
1215
1161
  */
1216
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, unknown, unknown>, TE extends Parser<Mode, unknown, unknown>, TF extends Parser<Mode, unknown, unknown>, TG extends Parser<Mode, unknown, unknown>, TH extends Parser<Mode, unknown, unknown>, TI extends Parser<Mode, unknown, unknown>, TJ extends Parser<Mode, unknown, unknown>>(a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC, d: ExtractObjectTypes<TD> extends never ? never : TD, e: ExtractObjectTypes<TE> extends never ? never : TE, f: ExtractObjectTypes<TF> extends never ? never : TF, g: ExtractObjectTypes<TG> extends never ? never : TG, h: ExtractObjectTypes<TH> extends never ? never : TH, i: ExtractObjectTypes<TI> extends never ? never : TI, j: ExtractObjectTypes<TJ> extends never ? never : TJ): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>, ExtractMode<TD>, ExtractMode<TE>, ExtractMode<TF>, ExtractMode<TG>, ExtractMode<TH>, ExtractMode<TI>, ExtractMode<TJ>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE> & ExtractObjectTypes<TF> & ExtractObjectTypes<TG> & ExtractObjectTypes<TH> & ExtractObjectTypes<TI> & ExtractObjectTypes<TJ>, Record<string | symbol, unknown>>;
1162
+ declare function merge<const TParsers extends MergeParsers>(label: string, ...rest: [...parsers: EnsureMergeParsers<TParsers>, options: MergeTailOptions] & MergeArityGuard<TParsers>): MergeReturnType<TParsers>;
1217
1163
  /**
1218
- * Merges multiple {@link object} parsers into a single {@link object} parser
1219
- * with a label for documentation and help text organization.
1220
- * It is useful for combining multiple {@link object} parsers so that
1221
- * the unified parser produces a single object containing all the values
1222
- * from the individual parsers while separating the fields into multiple
1223
- * groups.
1224
- * @template TA The type of the first parser.
1225
- * @template TB The type of the second parser.
1226
- * @template TC The type of the third parser.
1227
- * @template TD The type of the fourth parser.
1228
- * @template TE The type of the fifth parser.
1229
- * @template TF The type of the sixth parser.
1230
- * @template TG The type of the seventh parser.
1231
- * @template TH The type of the eighth parser.
1232
- * @template TI The type of the ninth parser.
1233
- * @template TJ The type of the tenth parser.
1234
- * @param label A descriptive label for this merged group, used for
1235
- * documentation and help messages.
1236
- * @param a The first {@link object} parser to merge.
1237
- * @param b The second {@link object} parser to merge.
1238
- * @param c The third {@link object} parser to merge.
1239
- * @param d The fourth {@link object} parser to merge.
1240
- * @param e The fifth {@link object} parser to merge.
1241
- * @param f The sixth {@link object} parser to merge.
1242
- * @param g The seventh {@link object} parser to merge.
1243
- * @param h The eighth {@link object} parser to merge.
1244
- * @param i The ninth {@link object} parser to merge.
1245
- * @param j The tenth {@link object} parser to merge.
1246
- * @return A new {@link object} parser that combines the values and states
1247
- * of the parsers into a single object.
1248
- * @since 0.4.0
1249
- */
1250
- declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Parser<Mode, unknown, unknown>, TC extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, unknown, unknown>, TE extends Parser<Mode, unknown, unknown>, TF extends Parser<Mode, unknown, unknown>, TG extends Parser<Mode, unknown, unknown>, TH extends Parser<Mode, unknown, unknown>, TI extends Parser<Mode, unknown, unknown>, TJ extends Parser<Mode, unknown, unknown>>(label: string, a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC, d: ExtractObjectTypes<TD> extends never ? never : TD, e: ExtractObjectTypes<TE> extends never ? never : TE, f: ExtractObjectTypes<TF> extends never ? never : TF, g: ExtractObjectTypes<TG> extends never ? never : TG, h: ExtractObjectTypes<TH> extends never ? never : TH, i: ExtractObjectTypes<TI> extends never ? never : TI, j: ExtractObjectTypes<TJ> extends never ? never : TJ): Parser<CombineModes<readonly [ExtractMode<TA>, ExtractMode<TB>, ExtractMode<TC>, ExtractMode<TD>, ExtractMode<TE>, ExtractMode<TF>, ExtractMode<TG>, ExtractMode<TH>, ExtractMode<TI>, ExtractMode<TJ>]>, ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE> & ExtractObjectTypes<TF> & ExtractObjectTypes<TG> & ExtractObjectTypes<TH> & ExtractObjectTypes<TI> & ExtractObjectTypes<TJ>, Record<string | symbol, unknown>>;
1164
+ * Merges multiple object-like parsers into one parser.
1165
+ *
1166
+ * This is useful for combining separate object parsers into one
1167
+ * unified parser while keeping fields grouped by parser boundaries.
1168
+ *
1169
+ * @param parsers Parsers to merge in declaration order.
1170
+ * @returns A parser that merges parsed object fields from all parsers.
1171
+ * Type inference is precise for tuple calls up to 15 parser arguments.
1172
+ * @since 0.1.0
1173
+ */
1174
+ declare function merge<const TParsers extends MergeParsers>(...parsers: EnsureMergeParsers<TParsers> & MergeArityGuard<TParsers>): MergeReturnType<TParsers>;
1175
+ type ConcatParserArity = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15;
1176
+ type ConcatArityLimitError = {
1177
+ readonly __optiqueConcatArityLimit: "concat() requires between 1 and 15 parser arguments. Nest concat() to combine more.";
1178
+ };
1179
+ type ConcatParsers = readonly Parser<Mode, readonly unknown[], unknown>[];
1180
+ type ConcatArityGuard<TParsers extends readonly unknown[]> = IsTuple<TParsers> extends true ? TParsers["length"] extends ConcatParserArity ? unknown : ConcatArityLimitError : unknown;
1181
+ type ConcatStates<TParsers extends ConcatParsers> = { [K in keyof TParsers]: TParsers[K] extends Parser<Mode, readonly unknown[], infer TState> ? TState : never };
1182
+ type ConcatTupleValues<TParsers extends ConcatParsers> = TParsers extends readonly [Parser<Mode, infer THead extends readonly unknown[], unknown>, ...infer TRest extends ConcatParsers] ? [...THead, ...ConcatTupleValues<TRest>] : [];
1183
+ type ConcatValues<TParsers extends ConcatParsers> = IsTuple<TParsers> extends true ? ConcatTupleValues<TParsers> : readonly unknown[];
1251
1184
  /**
1252
- * Concatenates two {@link tuple} parsers into a single parser that produces
1253
- * a flattened tuple containing the values from both parsers in order.
1185
+ * Concatenates tuple parsers into one parser with a flattened tuple value.
1254
1186
  *
1255
- * This is similar to {@link merge} for object parsers, but operates on tuple
1256
- * parsers and preserves the sequential, positional nature of tuples by
1257
- * flattening the results into a single tuple array.
1187
+ * Unlike {@link merge}, which combines object fields, this combines tuple
1188
+ * entries in order into one flattened tuple value.
1258
1189
  *
1259
1190
  * @example
1260
1191
  * ```typescript
1192
+ * import { parse } from "@optique/core/parser";
1193
+ * import { option } from "@optique/core/primitives";
1194
+ * import { integer, string } from "@optique/core/valueparser";
1195
+ *
1261
1196
  * const basicTuple = tuple([
1262
1197
  * option("-v", "--verbose"),
1263
1198
  * option("-p", "--port", integer()),
@@ -1269,86 +1204,21 @@ declare function merge<TA extends Parser<Mode, unknown, unknown>, TB extends Par
1269
1204
  * ]);
1270
1205
  *
1271
1206
  * const combined = concat(basicTuple, serverTuple);
1272
- * // Type: Parser<[boolean, number, string, boolean], [BasicState, ServerState]>
1207
+ * // Inferred type: Parser<..., [boolean, number, string, boolean], ...>
1273
1208
  *
1274
- * const result = parse(combined, ["-v", "-p", "8080", "-h", "localhost", "-d"]);
1209
+ * const result = parse(
1210
+ * combined,
1211
+ * ["-v", "-p", "8080", "-h", "localhost", "-d"],
1212
+ * );
1275
1213
  * // result.value: [true, 8080, "localhost", true]
1276
1214
  * ```
1277
1215
  *
1278
- * @template TA The value type of the first tuple parser.
1279
- * @template TB The value type of the second tuple parser.
1280
- * @template TStateA The state type of the first tuple parser.
1281
- * @template TStateB The state type of the second tuple parser.
1282
- * @param a The first {@link tuple} parser to concatenate.
1283
- * @param b The second {@link tuple} parser to concatenate.
1284
- * @return A new {@link tuple} parser that combines the values of both parsers
1285
- * into a single flattened tuple.
1286
- * @since 0.2.0
1287
- */
1288
- declare function concat<MA extends Mode, MB extends Mode, TA extends readonly unknown[], TB extends readonly unknown[], TStateA, TStateB>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>): Parser<CombineModes<readonly [MA, MB]>, [...TA, ...TB], [TStateA, TStateB]>;
1289
- /**
1290
- * Concatenates three {@link tuple} parsers into a single parser that produces
1291
- * a flattened tuple containing the values from all parsers in order.
1292
- *
1293
- * @template TA The value type of the first tuple parser.
1294
- * @template TB The value type of the second tuple parser.
1295
- * @template TC The value type of the third tuple parser.
1296
- * @template TStateA The state type of the first tuple parser.
1297
- * @template TStateB The state type of the second tuple parser.
1298
- * @template TStateC The state type of the third tuple parser.
1299
- * @param a The first {@link tuple} parser to concatenate.
1300
- * @param b The second {@link tuple} parser to concatenate.
1301
- * @param c The third {@link tuple} parser to concatenate.
1302
- * @return A new {@link tuple} parser that combines the values of all parsers
1303
- * into a single flattened tuple.
1216
+ * @param parsers Tuple parsers to concatenate.
1217
+ * @returns A parser with flattened tuple values from all parsers.
1218
+ * Type inference is precise for tuple calls up to 15 parser arguments.
1304
1219
  * @since 0.2.0
1305
1220
  */
1306
- declare function concat<MA extends Mode, MB extends Mode, MC extends Mode, TA extends readonly unknown[], TB extends readonly unknown[], TC extends readonly unknown[], TStateA, TStateB, TStateC>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>): Parser<CombineModes<readonly [MA, MB, MC]>, [...TA, ...TB, ...TC], [TStateA, TStateB, TStateC]>;
1307
- /**
1308
- * Concatenates four {@link tuple} parsers into a single parser that produces
1309
- * a flattened tuple containing the values from all parsers in order.
1310
- *
1311
- * @template TA The value type of the first tuple parser.
1312
- * @template TB The value type of the second tuple parser.
1313
- * @template TC The value type of the third tuple parser.
1314
- * @template TD The value type of the fourth tuple parser.
1315
- * @template TStateA The state type of the first tuple parser.
1316
- * @template TStateB The state type of the second tuple parser.
1317
- * @template TStateC The state type of the third tuple parser.
1318
- * @template TStateD The state type of the fourth tuple parser.
1319
- * @param a The first {@link tuple} parser to concatenate.
1320
- * @param b The second {@link tuple} parser to concatenate.
1321
- * @param c The third {@link tuple} parser to concatenate.
1322
- * @param d The fourth {@link tuple} parser to concatenate.
1323
- * @return A new {@link tuple} parser that combines the values of all parsers
1324
- * into a single flattened tuple.
1325
- * @since 0.2.0
1326
- */
1327
- declare function concat<MA extends Mode, MB extends Mode, MC extends Mode, MD extends Mode, TA extends readonly unknown[], TB extends readonly unknown[], TC extends readonly unknown[], TD extends readonly unknown[], TStateA, TStateB, TStateC, TStateD>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>, d: Parser<MD, TD, TStateD>): Parser<CombineModes<readonly [MA, MB, MC, MD]>, [...TA, ...TB, ...TC, ...TD], [TStateA, TStateB, TStateC, TStateD]>;
1328
- /**
1329
- * Concatenates five {@link tuple} parsers into a single parser that produces
1330
- * a flattened tuple containing the values from all parsers in order.
1331
- *
1332
- * @template TA The value type of the first tuple parser.
1333
- * @template TB The value type of the second tuple parser.
1334
- * @template TC The value type of the third tuple parser.
1335
- * @template TD The value type of the fourth tuple parser.
1336
- * @template TE The value type of the fifth tuple parser.
1337
- * @template TStateA The state type of the first tuple parser.
1338
- * @template TStateB The state type of the second tuple parser.
1339
- * @template TStateC The state type of the third tuple parser.
1340
- * @template TStateD The state type of the fourth tuple parser.
1341
- * @template TStateE The state type of the fifth tuple parser.
1342
- * @param a The first {@link tuple} parser to concatenate.
1343
- * @param b The second {@link tuple} parser to concatenate.
1344
- * @param c The third {@link tuple} parser to concatenate.
1345
- * @param d The fourth {@link tuple} parser to concatenate.
1346
- * @param e The fifth {@link tuple} parser to concatenate.
1347
- * @return A new {@link tuple} parser that combines the values of all parsers
1348
- * into a single flattened tuple.
1349
- * @since 0.2.0
1350
- */
1351
- declare function concat<MA extends Mode, MB extends Mode, MC extends Mode, MD extends Mode, ME extends Mode, TA extends readonly unknown[], TB extends readonly unknown[], TC extends readonly unknown[], TD extends readonly unknown[], TE extends readonly unknown[], TStateA, TStateB, TStateC, TStateD, TStateE>(a: Parser<MA, TA, TStateA>, b: Parser<MB, TB, TStateB>, c: Parser<MC, TC, TStateC>, d: Parser<MD, TD, TStateD>, e: Parser<ME, TE, TStateE>): Parser<CombineModes<readonly [MA, MB, MC, MD, ME]>, [...TA, ...TB, ...TC, ...TD, ...TE], [TStateA, TStateB, TStateC, TStateD, TStateE]>;
1221
+ declare function concat<const TParsers extends ConcatParsers>(...parsers: TParsers & ConcatArityGuard<TParsers>): Parser<CombineModes<{ readonly [K in keyof TParsers]: ExtractMode<TParsers[K]> }>, ConcatValues<TParsers>, ConcatStates<TParsers>>;
1352
1222
  /**
1353
1223
  * Wraps a parser with a group label for documentation purposes.
1354
1224
  *
@@ -1387,11 +1257,22 @@ declare function concat<MA extends Mode, MB extends Mode, MC extends Mode, MD ex
1387
1257
  * @param label A descriptive label for this parser group, used for
1388
1258
  * documentation and help text organization.
1389
1259
  * @param parser The parser to wrap with a group label.
1260
+ * @param options Optional visibility controls for the wrapped parser terms.
1390
1261
  * @returns A new parser that behaves identically to the input parser
1391
1262
  * but generates documentation within a labeled section.
1392
1263
  * @since 0.4.0
1393
1264
  */
1394
- declare function group<M extends Mode, TValue, TState>(label: string, parser: Parser<M, TValue, TState>): Parser<M, TValue, TState>;
1265
+ /**
1266
+ * Options for the {@link group} parser wrapper.
1267
+ * @since 1.0.0
1268
+ */
1269
+ interface GroupOptions {
1270
+ /**
1271
+ * Controls visibility of all terms emitted by this group.
1272
+ */
1273
+ readonly hidden?: HiddenVisibility;
1274
+ }
1275
+ declare function group<M extends Mode, TValue, TState>(label: string, parser: Parser<M, TValue, TState>, options?: GroupOptions): Parser<M, TValue, TState>;
1395
1276
  /**
1396
1277
  * Tagged union type representing which branch is selected.
1397
1278
  * Uses tagged union to avoid collision with discriminator values.
@@ -1476,4 +1357,4 @@ declare function conditional<TDiscriminator extends string, TBranches extends {
1476
1357
  */
1477
1358
  declare function conditional<TDiscriminator extends string, TBranches extends { [K in TDiscriminator]: Parser<Mode, unknown, unknown> }, TDefault extends Parser<Mode, unknown, unknown>, TD extends Parser<Mode, TDiscriminator, unknown>>(discriminator: TD, branches: TBranches, defaultBranch: TDefault, options?: ConditionalOptions): Parser<CombineModes<readonly [ExtractMode<TD>, ExtractMode<TDefault>, ...{ [K in keyof TBranches]: ExtractMode<TBranches[K]> }[keyof TBranches][]]>, ConditionalResultWithDefault<TDiscriminator, TBranches, TDefault>, ConditionalState<TDiscriminator>>;
1478
1359
  //#endregion
1479
- export { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple };
1360
+ export { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple };