@optique/core 1.0.0-dev.500 → 1.0.0-dev.504

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.
@@ -716,29 +716,41 @@ declare function or<MA extends Mode, MB extends Mode, MC extends Mode, MD extend
716
716
  /**
717
717
  * Creates a parser that combines two mutually exclusive parsers into one,
718
718
  * with custom error message options.
719
- * @template TA The type of the first parser.
720
- * @template TB The type of the second parser.
719
+ * @template MA The mode of the first parser.
720
+ * @template MB The mode of the second parser.
721
+ * @template TA The type of the value returned by the first parser.
722
+ * @template TB The type of the value returned by the second parser.
723
+ * @template TStateA The type of the state used by the first parser.
724
+ * @template TStateB The type of the state used by the second parser.
721
725
  * @param a The first {@link Parser} to try.
722
726
  * @param b The second {@link Parser} to try.
723
727
  * @param options Custom error message options.
724
- * @return A {@link Parser} that tries to parse using the provided parsers.
728
+ * @return A {@link Parser} that tries to parse using the provided parsers
729
+ * in order, returning the result of the first successful parser.
725
730
  * @since 0.5.0
726
731
  */
727
- 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>]>;
732
+ 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>]>;
728
733
  /**
729
734
  * Creates a parser that combines three mutually exclusive parsers into one,
730
735
  * with custom error message options.
731
- * @template TA The type of the first parser.
732
- * @template TB The type of the second parser.
733
- * @template TC The type of the third parser.
736
+ * @template MA The mode of the first parser.
737
+ * @template MB The mode of the second parser.
738
+ * @template MC The mode of the third parser.
739
+ * @template TA The type of the value returned by the first parser.
740
+ * @template TB The type of the value returned by the second parser.
741
+ * @template TC The type of the value returned by the third parser.
742
+ * @template TStateA The type of the state used by the first parser.
743
+ * @template TStateB The type of the state used by the second parser.
744
+ * @template TStateC The type of the state used by the third parser.
734
745
  * @param a The first {@link Parser} to try.
735
746
  * @param b The second {@link Parser} to try.
736
747
  * @param c The third {@link Parser} to try.
737
748
  * @param options Custom error message options.
738
- * @return A {@link Parser} that tries to parse using the provided parsers.
749
+ * @return A {@link Parser} that tries to parse using the provided parsers
750
+ * in order, returning the result of the first successful parser.
739
751
  * @since 0.5.0
740
752
  */
741
- 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>]>;
753
+ 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>]>;
742
754
  /**
743
755
  * Creates a parser that tries each parser in sequence until one succeeds,
744
756
  * with custom error message options.
@@ -748,6 +760,12 @@ declare function or<TA extends Parser<Mode, unknown, unknown>, TB extends Parser
748
760
  * @since 0.5.0
749
761
  */
750
762
  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>]>;
763
+ /**
764
+ * Creates a parser that tries each parser in sequence until one succeeds.
765
+ * @param parsers Parsers to try in order.
766
+ * @returns A parser that succeeds if any of the input parsers succeed.
767
+ * @since 0.5.0
768
+ */
751
769
  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>]>;
752
770
  /**
753
771
  * Options for customizing error messages in the {@link longestMatch}
@@ -716,29 +716,41 @@ declare function or<MA extends Mode, MB extends Mode, MC extends Mode, MD extend
716
716
  /**
717
717
  * Creates a parser that combines two mutually exclusive parsers into one,
718
718
  * with custom error message options.
719
- * @template TA The type of the first parser.
720
- * @template TB The type of the second parser.
719
+ * @template MA The mode of the first parser.
720
+ * @template MB The mode of the second parser.
721
+ * @template TA The type of the value returned by the first parser.
722
+ * @template TB The type of the value returned by the second parser.
723
+ * @template TStateA The type of the state used by the first parser.
724
+ * @template TStateB The type of the state used by the second parser.
721
725
  * @param a The first {@link Parser} to try.
722
726
  * @param b The second {@link Parser} to try.
723
727
  * @param options Custom error message options.
724
- * @return A {@link Parser} that tries to parse using the provided parsers.
728
+ * @return A {@link Parser} that tries to parse using the provided parsers
729
+ * in order, returning the result of the first successful parser.
725
730
  * @since 0.5.0
726
731
  */
727
- 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>]>;
732
+ 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>]>;
728
733
  /**
729
734
  * Creates a parser that combines three mutually exclusive parsers into one,
730
735
  * with custom error message options.
731
- * @template TA The type of the first parser.
732
- * @template TB The type of the second parser.
733
- * @template TC The type of the third parser.
736
+ * @template MA The mode of the first parser.
737
+ * @template MB The mode of the second parser.
738
+ * @template MC The mode of the third parser.
739
+ * @template TA The type of the value returned by the first parser.
740
+ * @template TB The type of the value returned by the second parser.
741
+ * @template TC The type of the value returned by the third parser.
742
+ * @template TStateA The type of the state used by the first parser.
743
+ * @template TStateB The type of the state used by the second parser.
744
+ * @template TStateC The type of the state used by the third parser.
734
745
  * @param a The first {@link Parser} to try.
735
746
  * @param b The second {@link Parser} to try.
736
747
  * @param c The third {@link Parser} to try.
737
748
  * @param options Custom error message options.
738
- * @return A {@link Parser} that tries to parse using the provided parsers.
749
+ * @return A {@link Parser} that tries to parse using the provided parsers
750
+ * in order, returning the result of the first successful parser.
739
751
  * @since 0.5.0
740
752
  */
741
- 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>]>;
753
+ 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>]>;
742
754
  /**
743
755
  * Creates a parser that tries each parser in sequence until one succeeds,
744
756
  * with custom error message options.
@@ -748,6 +760,12 @@ declare function or<TA extends Parser<Mode, unknown, unknown>, TB extends Parser
748
760
  * @since 0.5.0
749
761
  */
750
762
  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>]>;
763
+ /**
764
+ * Creates a parser that tries each parser in sequence until one succeeds.
765
+ * @param parsers Parsers to try in order.
766
+ * @returns A parser that succeeds if any of the input parsers succeed.
767
+ * @since 0.5.0
768
+ */
751
769
  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>]>;
752
770
  /**
753
771
  * Options for customizing error messages in the {@link longestMatch}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.500+426d7651",
3
+ "version": "1.0.0-dev.504+94f6f199",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",