@optique/core 0.3.0-dev.35 → 0.3.0-dev.36

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.
package/dist/parser.cjs CHANGED
@@ -525,12 +525,13 @@ function optional(parser) {
525
525
  * a specified default value.
526
526
  * @template TValue The type of the value returned by the wrapped parser.
527
527
  * @template TState The type of the state used by the wrapped parser.
528
+ * @template TDefault The type of the default value.
528
529
  * @param parser The {@link Parser} to wrap with default behavior.
529
530
  * @param defaultValue The default value to return when the wrapped parser
530
531
  * doesn't match or consume input. Can be a value of type
531
- * {@link TValue} or a function that returns such a value.
532
+ * {@link TDefault} or a function that returns such a value.
532
533
  * @returns A {@link Parser} that produces either the result of the wrapped parser
533
- * or the default value if the wrapped parser fails to match.
534
+ * or the default value if the wrapped parser fails to match (union type {@link TValue} | {@link TDefault}).
534
535
  */
535
536
  function withDefault(parser, defaultValue) {
536
537
  return {
@@ -565,7 +566,7 @@ function withDefault(parser, defaultValue) {
565
566
  return parser.complete(state[0]);
566
567
  },
567
568
  getDocFragments(state, upperDefaultValue) {
568
- return parser.getDocFragments(typeof state === "undefined" ? parser.initialState : state[0], upperDefaultValue == null ? typeof defaultValue === "function" ? defaultValue() : defaultValue : upperDefaultValue);
569
+ return parser.getDocFragments(typeof state === "undefined" ? parser.initialState : state[0], upperDefaultValue != null ? upperDefaultValue : typeof defaultValue === "function" ? defaultValue() : defaultValue);
569
570
  }
570
571
  };
571
572
  }
package/dist/parser.d.cts CHANGED
@@ -271,14 +271,15 @@ declare function optional<TValue, TState>(parser: Parser<TValue, TState>): Parse
271
271
  * a specified default value.
272
272
  * @template TValue The type of the value returned by the wrapped parser.
273
273
  * @template TState The type of the state used by the wrapped parser.
274
+ * @template TDefault The type of the default value.
274
275
  * @param parser The {@link Parser} to wrap with default behavior.
275
276
  * @param defaultValue The default value to return when the wrapped parser
276
277
  * doesn't match or consume input. Can be a value of type
277
- * {@link TValue} or a function that returns such a value.
278
+ * {@link TDefault} or a function that returns such a value.
278
279
  * @returns A {@link Parser} that produces either the result of the wrapped parser
279
- * or the default value if the wrapped parser fails to match.
280
+ * or the default value if the wrapped parser fails to match (union type {@link TValue} | {@link TDefault}).
280
281
  */
281
- declare function withDefault<TValue, TState>(parser: Parser<TValue, TState>, defaultValue: TValue | (() => TValue)): Parser<TValue, [TState] | undefined>;
282
+ declare function withDefault<TValue, TState, TDefault = TValue>(parser: Parser<TValue, TState>, defaultValue: TDefault | (() => TDefault)): Parser<TValue | TDefault, [TState] | undefined>;
282
283
  /**
283
284
  * Creates a parser that transforms the result value of another parser using
284
285
  * a mapping function. This enables value transformation while preserving
package/dist/parser.d.ts CHANGED
@@ -271,14 +271,15 @@ declare function optional<TValue, TState>(parser: Parser<TValue, TState>): Parse
271
271
  * a specified default value.
272
272
  * @template TValue The type of the value returned by the wrapped parser.
273
273
  * @template TState The type of the state used by the wrapped parser.
274
+ * @template TDefault The type of the default value.
274
275
  * @param parser The {@link Parser} to wrap with default behavior.
275
276
  * @param defaultValue The default value to return when the wrapped parser
276
277
  * doesn't match or consume input. Can be a value of type
277
- * {@link TValue} or a function that returns such a value.
278
+ * {@link TDefault} or a function that returns such a value.
278
279
  * @returns A {@link Parser} that produces either the result of the wrapped parser
279
- * or the default value if the wrapped parser fails to match.
280
+ * or the default value if the wrapped parser fails to match (union type {@link TValue} | {@link TDefault}).
280
281
  */
281
- declare function withDefault<TValue, TState>(parser: Parser<TValue, TState>, defaultValue: TValue | (() => TValue)): Parser<TValue, [TState] | undefined>;
282
+ declare function withDefault<TValue, TState, TDefault = TValue>(parser: Parser<TValue, TState>, defaultValue: TDefault | (() => TDefault)): Parser<TValue | TDefault, [TState] | undefined>;
282
283
  /**
283
284
  * Creates a parser that transforms the result value of another parser using
284
285
  * a mapping function. This enables value transformation while preserving
package/dist/parser.js CHANGED
@@ -525,12 +525,13 @@ function optional(parser) {
525
525
  * a specified default value.
526
526
  * @template TValue The type of the value returned by the wrapped parser.
527
527
  * @template TState The type of the state used by the wrapped parser.
528
+ * @template TDefault The type of the default value.
528
529
  * @param parser The {@link Parser} to wrap with default behavior.
529
530
  * @param defaultValue The default value to return when the wrapped parser
530
531
  * doesn't match or consume input. Can be a value of type
531
- * {@link TValue} or a function that returns such a value.
532
+ * {@link TDefault} or a function that returns such a value.
532
533
  * @returns A {@link Parser} that produces either the result of the wrapped parser
533
- * or the default value if the wrapped parser fails to match.
534
+ * or the default value if the wrapped parser fails to match (union type {@link TValue} | {@link TDefault}).
534
535
  */
535
536
  function withDefault(parser, defaultValue) {
536
537
  return {
@@ -565,7 +566,7 @@ function withDefault(parser, defaultValue) {
565
566
  return parser.complete(state[0]);
566
567
  },
567
568
  getDocFragments(state, upperDefaultValue) {
568
- return parser.getDocFragments(typeof state === "undefined" ? parser.initialState : state[0], upperDefaultValue == null ? typeof defaultValue === "function" ? defaultValue() : defaultValue : upperDefaultValue);
569
+ return parser.getDocFragments(typeof state === "undefined" ? parser.initialState : state[0], upperDefaultValue != null ? upperDefaultValue : typeof defaultValue === "function" ? defaultValue() : defaultValue);
569
570
  }
570
571
  };
571
572
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "0.3.0-dev.35+3445f3b8",
3
+ "version": "0.3.0-dev.36+680746e6",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",