@optique/core 0.5.0-dev.79 → 0.5.0-dev.80

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.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import { Message } from "./message.js";
2
- import { OptionName, Usage } from "./usage.js";
2
+ import { Usage } from "./usage.js";
3
3
  import { DocFragments, DocPage } from "./doc.js";
4
- import { ValueParser, ValueParserResult } from "./valueparser.js";
4
+ import { ValueParserResult } from "./valueparser.js";
5
+ import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, optional, withDefault } from "./modifiers.js";
6
+ import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, argument, command, constant, flag, option } from "./primitives.js";
7
+ import { LongestMatchErrorOptions, LongestMatchOptions, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, concat, group, longestMatch, merge, object, or, tuple } from "./constructs.js";
5
8
 
6
9
  //#region src/parser.d.ts
7
10
 
@@ -144,1239 +147,6 @@ type ParserResult<TState> = {
144
147
  */
145
148
  readonly error: Message;
146
149
  };
147
- /**
148
- * Creates a parser that always succeeds without consuming any input and
149
- * produces a constant value of the type {@link T}.
150
- * @template T The type of the constant value produced by the parser.
151
- */
152
- declare function constant<const T>(value: T): Parser<T, T>;
153
- /**
154
- * Options for the {@link option} parser.
155
- */
156
- interface OptionOptions {
157
- /**
158
- * The description of the option, which can be used for help messages.
159
- */
160
- readonly description?: Message;
161
- }
162
- /**
163
- * Creates a parser for various styles of command-line options that take an
164
- * argument value, such as `--option=value`, `-o value`, or `/option:value`.
165
- * @template T The type of value this parser produces.
166
- * @param args The {@link OptionName}s to parse, followed by
167
- * a {@link ValueParser} that defines how to parse the value of
168
- * the option. If no value parser is provided, the option is
169
- * treated as a boolean flag.
170
- * @returns A {@link Parser} that can parse the specified options and their
171
- * values.
172
- */
173
- declare function option<T>(...args: readonly [...readonly OptionName[], ValueParser<T>]): Parser<T, ValueParserResult<T> | undefined>;
174
- /**
175
- * Creates a parser for various styles of command-line options that take an
176
- * argument value, such as `--option=value`, `-o value`, or `/option:value`.
177
- * @template T The type of value this parser produces.
178
- * @param args The {@link OptionName}s to parse, followed by
179
- * a {@link ValueParser} that defines how to parse the value of
180
- * the option, and an optional {@link OptionOptions} object
181
- * that allows you to specify a description or other metadata.
182
- * @returns A {@link Parser} that can parse the specified options and their
183
- * values.
184
- */
185
- declare function option<T>(...args: readonly [...readonly OptionName[], ValueParser<T>, OptionOptions]): Parser<T, ValueParserResult<T> | undefined>;
186
- /**
187
- * Creates a parser for various styles of command-line options that do not
188
- * take an argument value, such as `--option`, `-o`, or `/option`.
189
- * @param optionNames The {@link OptionName}s to parse.
190
- * @return A {@link Parser} that can parse the specified options as Boolean
191
- * flags, producing `true` if the option is present.
192
- */
193
- declare function option(...optionNames: readonly OptionName[]): Parser<boolean, ValueParserResult<boolean> | undefined>;
194
- /**
195
- * Creates a parser for various styles of command-line options that take an
196
- * argument value, such as `--option=value`, `-o value`, or `/option:value`.
197
- * @param args The {@link OptionName}s to parse, followed by
198
- * an optional {@link OptionOptions} object that allows you to
199
- * specify a description or other metadata.
200
- * @returns A {@link Parser} that can parse the specified options and their
201
- * values.
202
- */
203
- declare function option(...args: readonly [...readonly OptionName[], OptionOptions]): Parser<boolean, ValueParserResult<boolean> | undefined>;
204
- /**
205
- * Options for the {@link flag} parser.
206
- */
207
- interface FlagOptions {
208
- /**
209
- * The description of the flag, which can be used for help messages.
210
- */
211
- readonly description?: Message;
212
- }
213
- /**
214
- * Creates a parser for command-line flags that must be explicitly provided.
215
- * Unlike {@link option}, this parser fails if the flag is not present, making
216
- * it suitable for required boolean flags that don't have a meaningful default.
217
- *
218
- * The key difference from {@link option} is:
219
- * - {@link option} without a value parser: Returns `false` when not present
220
- * - {@link flag}: Fails parsing when not present, only produces `true`
221
- *
222
- * This is useful for dependent options where the presence of a flag changes
223
- * the shape of the result type.
224
- *
225
- * @param args The {@link OptionName}s to parse, followed by an optional
226
- * {@link FlagOptions} object that allows you to specify
227
- * a description or other metadata.
228
- * @returns A {@link Parser} that produces `true` when the flag is present
229
- * and fails when it is not present.
230
- *
231
- * @example
232
- * ```typescript
233
- * // Basic flag usage
234
- * const parser = flag("-f", "--force");
235
- * // Succeeds with true: parse(parser, ["-f"])
236
- * // Fails: parse(parser, [])
237
- *
238
- * // With description
239
- * const verboseFlag = flag("-v", "--verbose", {
240
- * description: "Enable verbose output"
241
- * });
242
- * ```
243
- */
244
- declare function flag(...args: readonly [...readonly OptionName[], FlagOptions] | readonly OptionName[]): Parser<true, ValueParserResult<true> | undefined>;
245
- /**
246
- * Options for the {@link argument} parser.
247
- */
248
- interface ArgumentOptions {
249
- /**
250
- * The description of the argument, which can be used for help messages.
251
- */
252
- readonly description?: Message;
253
- }
254
- /**
255
- * Creates a parser that expects a single argument value.
256
- * This parser is typically used for positional arguments
257
- * that are not options or flags.
258
- * @template T The type of the value produced by the parser.
259
- * @param valueParser The {@link ValueParser} that defines how to parse
260
- * the argument value.
261
- * @param options Optional configuration for the argument parser,
262
- * allowing you to specify a description or other metadata.
263
- * @returns A {@link Parser} that expects a single argument value and produces
264
- * the parsed value of type {@link T}.
265
- */
266
- declare function argument<T>(valueParser: ValueParser<T>, options?: ArgumentOptions): Parser<T, ValueParserResult<T> | undefined>;
267
- /**
268
- * Creates a parser that makes another parser optional, allowing it to succeed
269
- * without consuming input if the wrapped parser fails to match.
270
- * If the wrapped parser succeeds, this returns its value.
271
- * If the wrapped parser fails, this returns `undefined` without consuming input.
272
- * @template TValue The type of the value returned by the wrapped parser.
273
- * @template TState The type of the state used by the wrapped parser.
274
- * @param parser The {@link Parser} to make optional.
275
- * @returns A {@link Parser} that produces either the result of the wrapped parser
276
- * or `undefined` if the wrapped parser fails to match.
277
- */
278
- declare function optional<TValue, TState>(parser: Parser<TValue, TState>): Parser<TValue | undefined, [TState] | undefined>;
279
- /**
280
- * Options for the {@link withDefault} parser.
281
- */
282
- interface WithDefaultOptions {
283
- /**
284
- * Custom message to display in help output instead of the formatted default value.
285
- * This allows showing descriptive text like "SERVICE_URL environment variable"
286
- * instead of the actual default value.
287
- *
288
- * @example
289
- * ```typescript
290
- * withDefault(
291
- * option("--url", url()),
292
- * process.env["SERVICE_URL"],
293
- * { message: message`${envVar("SERVICE_URL")} environment variable` }
294
- * )
295
- * ```
296
- */
297
- readonly message?: Message;
298
- }
299
- /**
300
- * Error type for structured error messages in {@link withDefault} default value callbacks.
301
- * Unlike regular errors that only support string messages, this error type accepts
302
- * a {@link Message} object that supports rich formatting, colors, and structured content.
303
- *
304
- * @example
305
- * ```typescript
306
- * withDefault(option("--url", url()), () => {
307
- * if (!process.env.INSTANCE_URL) {
308
- * throw new WithDefaultError(
309
- * message`Environment variable ${envVar("INSTANCE_URL")} is not set.`
310
- * );
311
- * }
312
- * return new URL(process.env.INSTANCE_URL);
313
- * })
314
- * ```
315
- *
316
- * @since 0.5.0
317
- */
318
- declare class WithDefaultError extends Error {
319
- /**
320
- * The structured message associated with this error.
321
- */
322
- readonly errorMessage: Message;
323
- /**
324
- * Creates a new WithDefaultError with a structured message.
325
- * @param message The structured {@link Message} describing the error.
326
- */
327
- constructor(message: Message);
328
- }
329
- /**
330
- * Creates a parser that makes another parser use a default value when it fails
331
- * to match or consume input. This is similar to {@link optional}, but instead
332
- * of returning `undefined` when the wrapped parser doesn't match, it returns
333
- * a specified default value.
334
- * @template TValue The type of the value returned by the wrapped parser.
335
- * @template TState The type of the state used by the wrapped parser.
336
- * @template TDefault The type of the default value.
337
- * @param parser The {@link Parser} to wrap with default behavior.
338
- * @param defaultValue The default value to return when the wrapped parser
339
- * doesn't match or consume input. Can be a value of type
340
- * {@link TDefault} or a function that returns such a value.
341
- * @returns A {@link Parser} that produces either the result of the wrapped parser
342
- * or the default value if the wrapped parser fails to match
343
- * (union type {@link TValue} | {@link TDefault}).
344
- */
345
- declare function withDefault<TValue, TState, TDefault = TValue>(parser: Parser<TValue, TState>, defaultValue: TDefault | (() => TDefault)): Parser<TValue | TDefault, [TState] | undefined>;
346
- /**
347
- * Creates a parser that makes another parser use a default value when it fails
348
- * to match or consume input. This is similar to {@link optional}, but instead
349
- * of returning `undefined` when the wrapped parser doesn't match, it returns
350
- * a specified default value.
351
- * @template TValue The type of the value returned by the wrapped parser.
352
- * @template TState The type of the state used by the wrapped parser.
353
- * @template TDefault The type of the default value.
354
- * @param parser The {@link Parser} to wrap with default behavior.
355
- * @param defaultValue The default value to return when the wrapped parser
356
- * doesn't match or consume input. Can be a value of type
357
- * {@link TDefault} or a function that returns such a value.
358
- * @param options Optional configuration including custom help display message.
359
- * @returns A {@link Parser} that produces either the result of the wrapped parser
360
- * or the default value if the wrapped parser fails to match
361
- * (union type {@link TValue} | {@link TDefault}).
362
- * @since 0.5.0
363
- */
364
- declare function withDefault<TValue, TState, TDefault = TValue>(parser: Parser<TValue, TState>, defaultValue: TDefault | (() => TDefault), options?: WithDefaultOptions): Parser<TValue | TDefault, [TState] | undefined>;
365
- /**
366
- * Creates a parser that transforms the result value of another parser using
367
- * a mapping function. This enables value transformation while preserving
368
- * the original parser's parsing logic and state management.
369
- *
370
- * The `map()` function is useful for:
371
- * - Converting parsed values to different types
372
- * - Applying transformations like string formatting or boolean inversion
373
- * - Computing derived values from parsed input
374
- * - Creating reusable transformations that can be applied to any parser
375
- *
376
- * @template T The type of the value produced by the original parser.
377
- * @template U The type of the value produced by the mapping function.
378
- * @template TState The type of the state used by the original parser.
379
- * @param parser The {@link Parser} whose result will be transformed.
380
- * @param transform A function that transforms the parsed value from type T to type U.
381
- * @returns A {@link Parser} that produces the transformed value of type U
382
- * while preserving the original parser's state type and parsing behavior.
383
- *
384
- * @example
385
- * ```typescript
386
- * // Transform boolean flag to its inverse
387
- * const parser = object({
388
- * disallow: map(option("--allow"), b => !b)
389
- * });
390
- *
391
- * // Transform string to uppercase
392
- * const upperParser = map(argument(string()), s => s.toUpperCase());
393
- *
394
- * // Transform number to formatted string
395
- * const prefixedParser = map(option("-n", integer()), n => `value: ${n}`);
396
- * ```
397
- */
398
- declare function map<T, U, TState>(parser: Parser<T, TState>, transform: (value: T) => U): Parser<U, TState>;
399
- /**
400
- * Options for the {@link multiple} parser.
401
- */
402
- interface MultipleOptions {
403
- /**
404
- * The minimum number of occurrences required for the parser to succeed.
405
- * If the number of occurrences is less than this value,
406
- * the parser will fail with an error.
407
- * @default `0`
408
- */
409
- readonly min?: number;
410
- /**
411
- * The maximum number of occurrences allowed for the parser.
412
- * If the number of occurrences exceeds this value,
413
- * the parser will fail with an error.
414
- * @default `Infinity`
415
- */
416
- readonly max?: number;
417
- }
418
- /**
419
- * Creates a parser that allows multiple occurrences of a given parser.
420
- * This parser can be used to parse multiple values of the same type,
421
- * such as multiple command-line arguments or options.
422
- * @template TValue The type of the value that the parser produces.
423
- * @template TState The type of the state used by the parser.
424
- * @param parser The {@link Parser} to apply multiple times.
425
- * @param options Optional configuration for the parser,
426
- * allowing you to specify the minimum and maximum number of
427
- * occurrences allowed.
428
- * @returns A {@link Parser} that produces an array of values
429
- * of type {@link TValue} and an array of states
430
- * of type {@link TState}.
431
- */
432
- declare function multiple<TValue, TState>(parser: Parser<TValue, TState>, options?: MultipleOptions): Parser<readonly TValue[], readonly TState[]>;
433
- /**
434
- * Creates a parser that combines multiple parsers into a single object parser.
435
- * Each parser in the object is applied to parse different parts of the input,
436
- * and the results are combined into an object with the same structure.
437
- * @template T A record type where each value is a {@link Parser}.
438
- * @param parsers An object containing named parsers that will be combined
439
- * into a single object parser.
440
- * @returns A {@link Parser} that produces an object with the same keys as
441
- * the input, where each value is the result of the corresponding
442
- * parser.
443
- */
444
- declare function object<T extends {
445
- readonly [key: string | symbol]: Parser<unknown, unknown>;
446
- }>(parsers: T): Parser<{ readonly [K in keyof T]: T[K]["$valueType"][number] extends (infer U) ? U : never }, { readonly [K in keyof T]: T[K]["$stateType"][number] extends (infer U2) ? U2 : never }>;
447
- /**
448
- * Creates a labeled parser that combines multiple parsers into a single
449
- * object parser with an associated label for documentation or error reporting.
450
- * @template T A record type where each value is a {@link Parser}.
451
- * @param label A descriptive label for this parser group, used for
452
- * documentation and error messages.
453
- * @param parsers An object containing named parsers that will be combined
454
- * into a single object parser.
455
- * @returns A {@link Parser} that produces an object with the same keys as
456
- * the input, where each value is the result of the corresponding
457
- * parser.
458
- */
459
- declare function object<T extends {
460
- readonly [key: string | symbol]: Parser<unknown, unknown>;
461
- }>(label: string, parsers: T): Parser<{ readonly [K in keyof T]: T[K]["$valueType"][number] extends (infer U) ? U : never }, { readonly [K in keyof T]: T[K]["$stateType"][number] extends (infer U2) ? U2 : never }>;
462
- /**
463
- * Creates a parser that combines multiple parsers into a sequential tuple parser.
464
- * The parsers are applied in the order they appear in the array, and all must
465
- * succeed for the tuple parser to succeed.
466
- * @template T A readonly array type where each element is a {@link Parser}.
467
- * @param parsers An array of parsers that will be applied sequentially
468
- * to create a tuple of their results.
469
- * @returns A {@link Parser} that produces a readonly tuple with the same length
470
- * as the input array, where each element is the result of the
471
- * corresponding parser.
472
- */
473
- declare function tuple<const T extends readonly Parser<unknown, unknown>[]>(parsers: T): Parser<{ readonly [K in keyof T]: T[K]["$valueType"][number] extends (infer U) ? U : never }, { readonly [K in keyof T]: T[K]["$stateType"][number] extends (infer U2) ? U2 : never }>;
474
- /**
475
- * Creates a labeled parser that combines multiple parsers into a sequential
476
- * tuple parser with an associated label for documentation or error reporting.
477
- * @template T A readonly array type where each element is a {@link Parser}.
478
- * @param label A descriptive label for this parser group, used for
479
- * documentation and error messages.
480
- * @param parsers An array of parsers that will be applied sequentially
481
- * to create a tuple of their results.
482
- * @returns A {@link Parser} that produces a readonly tuple with the same length
483
- * as the input array, where each element is the result of the
484
- * corresponding parser.
485
- */
486
- declare function tuple<const T extends readonly Parser<unknown, unknown>[]>(label: string, parsers: T): Parser<{ readonly [K in keyof T]: T[K]["$valueType"][number] extends (infer U) ? U : never }, { readonly [K in keyof T]: T[K]["$stateType"][number] extends (infer U2) ? U2 : never }>;
487
- /**
488
- * Creates a parser that combines two mutually exclusive parsers into one.
489
- * The resulting parser will try each of the provided parsers in order,
490
- * and return the result of the first successful parser.
491
- * @template TA The type of the value returned by the first parser.
492
- * @template TB The type of the value returned by the second parser.
493
- * @template TStateA The type of the state used by the first parser.
494
- * @template TStateB The type of the state used by the second parser.
495
- * @param a The first {@link Parser} to try.
496
- * @param b The second {@link Parser} to try.
497
- * @returns A {@link Parser} that tries to parse using the provided parsers
498
- * in order, returning the result of the first successful parser.
499
- */
500
- declare function or<TA, TB, TStateA, TStateB>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>): Parser<TA | TB, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>]>;
501
- /**
502
- * Creates a parser that combines three mutually exclusive parsers into one.
503
- * The resulting parser will try each of the provided parsers in order,
504
- * and return the result of the first successful parser.
505
- * @template TA The type of the value returned by the first parser.
506
- * @template TB The type of the value returned by the second parser.
507
- * @template TC The type of the value returned by the third parser.
508
- * @template TStateA The type of the state used by the first parser.
509
- * @template TStateB The type of the state used by the second parser.
510
- * @template TStateC The type of the state used by the third parser.
511
- * @param a The first {@link Parser} to try.
512
- * @param b The second {@link Parser} to try.
513
- * @param c The third {@link Parser} to try.
514
- * @return A {@link Parser} that tries to parse using the provided parsers
515
- * in order, returning the result of the first successful parser.
516
- */
517
- declare function or<TA, TB, TC, TStateA, TStateB, TStateC>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>, c: Parser<TC, TStateC>): Parser<TA | TB | TC, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>]>;
518
- /**
519
- * Creates a parser that combines four mutually exclusive parsers into one.
520
- * The resulting parser will try each of the provided parsers in order,
521
- * and return the result of the first successful parser.
522
- * @template TA The type of the value returned by the first parser.
523
- * @template TB The type of the value returned by the second parser.
524
- * @template TC The type of the value returned by the third parser.
525
- * @template TD The type of the value returned by the fourth parser.
526
- * @template TStateA The type of the state used by the first parser.
527
- * @template TStateB The type of the state used by the second parser.
528
- * @template TStateC The type of the state used by the third parser.
529
- * @template TStateD The type of the state used by the fourth parser.
530
- * @param a The first {@link Parser} to try.
531
- * @param b The second {@link Parser} to try.
532
- * @param c The third {@link Parser} to try.
533
- * @param d The fourth {@link Parser} to try.
534
- * @return A {@link Parser} that tries to parse using the provided parsers
535
- * in order, returning the result of the first successful parser.
536
- */
537
- declare function or<TA, TB, TC, TD, TStateA, TStateB, TStateC, TStateD>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>, c: Parser<TC, TStateC>, d: Parser<TD, TStateD>): Parser<TA | TB | TC | TD, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>]>;
538
- /**
539
- * Creates a parser that combines five mutually exclusive parsers into one.
540
- * The resulting parser will try each of the provided parsers in order,
541
- * and return the result of the first successful 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 TE The type of the value returned by the fifth parser.
547
- * @template TStateA The type of the state used by the first parser.
548
- * @template TStateB The type of the state used by the second parser.
549
- * @template TStateC The type of the state used by the third parser.
550
- * @template TStateD The type of the state used by the fourth parser.
551
- * @template TStateE The type of the state used by the fifth parser.
552
- * @param a The first {@link Parser} to try.
553
- * @param b The second {@link Parser} to try.
554
- * @param c The third {@link Parser} to try.
555
- * @param d The fourth {@link Parser} to try.
556
- * @param e The fifth {@link Parser} to try.
557
- * @return A {@link Parser} that tries to parse using the provided parsers
558
- * in order, returning the result of the first successful parser.
559
- */
560
- declare function or<TA, TB, TC, TD, TE, TStateA, TStateB, TStateC, TStateD, TStateE>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>, c: Parser<TC, TStateC>, d: Parser<TD, TStateD>, e: Parser<TE, TStateE>): Parser<TA | TB | TC | TD | TE, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>] | [4, ParserResult<TStateE>]>;
561
- /**
562
- * Creates a parser that combines six mutually exclusive parsers into one.
563
- * The resulting parser will try each of the provided parsers in order,
564
- * and return the result of the first successful parser.
565
- * @template TA The type of the value returned by the first parser.
566
- * @template TB The type of the value returned by the second parser.
567
- * @template TC The type of the value returned by the third parser.
568
- * @template TD The type of the value returned by the fourth parser.
569
- * @template TE The type of the value returned by the fifth parser.
570
- * @template TF The type of the value returned by the sixth parser.
571
- * @template TStateA The type of the state used by the first parser.
572
- * @template TStateB The type of the state used by the second parser.
573
- * @template TStateC The type of the state used by the third parser.
574
- * @template TStateD The type of the state used by the fourth parser.
575
- * @template TStateE The type of the state used by the fifth parser.
576
- * @template TStateF The type of the state used by the sixth parser.
577
- * @param a The first {@link Parser} to try.
578
- * @param b The second {@link Parser} to try.
579
- * @param c The third {@link Parser} to try.
580
- * @param d The fourth {@link Parser} to try.
581
- * @param e The fifth {@link Parser} to try.
582
- * @param f The sixth {@link Parser} to try.
583
- * @return A {@link Parser} that tries to parse using the provided parsers
584
- * in order, returning the result of the first successful parser.
585
- * @since 0.3.0
586
- */
587
- declare function or<TA, TB, TC, TD, TE, TF, TStateA, TStateB, TStateC, TStateD, TStateE, TStateF>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>, c: Parser<TC, TStateC>, d: Parser<TD, TStateD>, e: Parser<TE, TStateE>, f: Parser<TF, TStateF>): Parser<TA | TB | TC | TD | TE | TF, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>] | [4, ParserResult<TStateE>] | [5, ParserResult<TStateF>]>;
588
- /**
589
- * Creates a parser that combines seven mutually exclusive parsers into one.
590
- * The resulting parser will try each of the provided parsers in order,
591
- * and return the result of the first successful parser.
592
- * @template TA The type of the value returned by the first parser.
593
- * @template TB The type of the value returned by the second parser.
594
- * @template TC The type of the value returned by the third parser.
595
- * @template TD The type of the value returned by the fourth parser.
596
- * @template TE The type of the value returned by the fifth parser.
597
- * @template TF The type of the value returned by the sixth parser.
598
- * @template TG The type of the value returned by the seventh parser.
599
- * @template TStateA The type of the state used by the first parser.
600
- * @template TStateB The type of the state used by the second parser.
601
- * @template TStateC The type of the state used by the third parser.
602
- * @template TStateD The type of the state used by the fourth parser.
603
- * @template TStateE The type of the state used by the fifth parser.
604
- * @template TStateF The type of the state used by the sixth parser.
605
- * @template TStateG The type of the state used by the seventh parser.
606
- * @param a The first {@link Parser} to try.
607
- * @param b The second {@link Parser} to try.
608
- * @param c The third {@link Parser} to try.
609
- * @param d The fourth {@link Parser} to try.
610
- * @param e The fifth {@link Parser} to try.
611
- * @param f The sixth {@link Parser} to try.
612
- * @param g The seventh {@link Parser} to try.
613
- * @return A {@link Parser} that tries to parse using the provided parsers
614
- * in order, returning the result of the first successful parser.
615
- * @since 0.3.0
616
- */
617
- declare function or<TA, TB, TC, TD, TE, TF, TG, TStateA, TStateB, TStateC, TStateD, TStateE, TStateF, TStateG>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>, c: Parser<TC, TStateC>, d: Parser<TD, TStateD>, e: Parser<TE, TStateE>, f: Parser<TF, TStateF>, g: Parser<TG, TStateG>): Parser<TA | TB | TC | TD | TE | TF | TG, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>] | [4, ParserResult<TStateE>] | [5, ParserResult<TStateF>] | [6, ParserResult<TStateG>]>;
618
- /**
619
- * Creates a parser that combines eight mutually exclusive parsers into one.
620
- * The resulting parser will try each of the provided parsers in order,
621
- * and return the result of the first successful parser.
622
- * @template TA The type of the value returned by the first parser.
623
- * @template TB The type of the value returned by the second parser.
624
- * @template TC The type of the value returned by the third parser.
625
- * @template TD The type of the value returned by the fourth parser.
626
- * @template TE The type of the value returned by the fifth parser.
627
- * @template TF The type of the value returned by the sixth parser.
628
- * @template TG The type of the value returned by the seventh parser.
629
- * @template TH The type of the value returned by the eighth parser.
630
- * @template TStateA The type of the state used by the first parser.
631
- * @template TStateB The type of the state used by the second parser.
632
- * @template TStateC The type of the state used by the third parser.
633
- * @template TStateD The type of the state used by the fourth parser.
634
- * @template TStateE The type of the state used by the fifth parser.
635
- * @template TStateF The type of the state used by the sixth parser.
636
- * @template TStateG The type of the state used by the seventh parser.
637
- * @template TStateH The type of the state used by the eighth parser.
638
- * @param a The first {@link Parser} to try.
639
- * @param b The second {@link Parser} to try.
640
- * @param c The third {@link Parser} to try.
641
- * @param d The fourth {@link Parser} to try.
642
- * @param e The fifth {@link Parser} to try.
643
- * @param f The sixth {@link Parser} to try.
644
- * @param g The seventh {@link Parser} to try.
645
- * @param h The eighth {@link Parser} to try.
646
- * @return A {@link Parser} that tries to parse using the provided parsers
647
- * in order, returning the result of the first successful parser.
648
- * @since 0.3.0
649
- */
650
- declare function or<TA, TB, TC, TD, TE, TF, TG, TH, TStateA, TStateB, TStateC, TStateD, TStateE, TStateF, TStateG, TStateH>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>, c: Parser<TC, TStateC>, d: Parser<TD, TStateD>, e: Parser<TE, TStateE>, f: Parser<TF, TStateF>, g: Parser<TG, TStateG>, h: Parser<TH, TStateH>): Parser<TA | TB | TC | TD | TE | TF | TG | TH, 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>]>;
651
- /**
652
- * Creates a parser that combines nine mutually exclusive parsers into one.
653
- * The resulting parser will try each of the provided parsers in order,
654
- * and return the result of the first successful parser.
655
- * @template TA The type of the value returned by the first parser.
656
- * @template TB The type of the value returned by the second parser.
657
- * @template TC The type of the value returned by the third parser.
658
- * @template TD The type of the value returned by the fourth parser.
659
- * @template TE The type of the value returned by the fifth parser.
660
- * @template TF The type of the value returned by the sixth parser.
661
- * @template TG The type of the value returned by the seventh parser.
662
- * @template TH The type of the value returned by the eighth parser.
663
- * @template TI The type of the value returned by the ninth parser.
664
- * @template TStateA The type of the state used by the first parser.
665
- * @template TStateB The type of the state used by the second parser.
666
- * @template TStateC The type of the state used by the third parser.
667
- * @template TStateD The type of the state used by the fourth parser.
668
- * @template TStateE The type of the state used by the fifth parser.
669
- * @template TStateF The type of the state used by the sixth parser.
670
- * @template TStateG The type of the state used by the seventh parser.
671
- * @template TStateH The type of the state used by the eighth parser.
672
- * @template TStateI The type of the state used by the ninth parser.
673
- * @param a The first {@link Parser} to try.
674
- * @param b The second {@link Parser} to try.
675
- * @param c The third {@link Parser} to try.
676
- * @param d The fourth {@link Parser} to try.
677
- * @param e The fifth {@link Parser} to try.
678
- * @param f The sixth {@link Parser} to try.
679
- * @param g The seventh {@link Parser} to try.
680
- * @param h The eighth {@link Parser} to try.
681
- * @param i The ninth {@link Parser} to try.
682
- * @return A {@link Parser} that tries to parse using the provided parsers
683
- * in order, returning the result of the first successful parser.
684
- * @since 0.3.0
685
- */
686
- declare function or<TA, TB, TC, TD, TE, TF, TG, TH, TI, TStateA, TStateB, TStateC, TStateD, TStateE, TStateF, TStateG, TStateH, TStateI>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>, c: Parser<TC, TStateC>, d: Parser<TD, TStateD>, e: Parser<TE, TStateE>, f: Parser<TF, TStateF>, g: Parser<TG, TStateG>, h: Parser<TH, TStateH>, i: Parser<TI, TStateI>): Parser<TA | TB | TC | TD | TE | TF | TG | TH | TI, 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>]>;
687
- /**
688
- * Creates a parser that combines ten mutually exclusive parsers into one.
689
- * The resulting parser will try each of the provided parsers in order,
690
- * and return the result of the first successful parser.
691
- * @template TA The type of the value returned by the first parser.
692
- * @template TB The type of the value returned by the second parser.
693
- * @template TC The type of the value returned by the third parser.
694
- * @template TD The type of the value returned by the fourth parser.
695
- * @template TE The type of the value returned by the fifth parser.
696
- * @template TF The type of the value returned by the sixth parser.
697
- * @template TG The type of the value returned by the seventh parser.
698
- * @template TH The type of the value returned by the eighth parser.
699
- * @template TI The type of the value returned by the ninth parser.
700
- * @template TJ The type of the value returned by the tenth parser.
701
- * @template TStateA The type of the state used by the first parser.
702
- * @template TStateB The type of the state used by the second parser.
703
- * @template TStateC The type of the state used by the third parser.
704
- * @template TStateD The type of the state used by the fourth parser.
705
- * @template TStateE The type of the state used by the fifth parser.
706
- * @template TStateF The type of the state used by the sixth parser.
707
- * @template TStateG The type of the state used by the seventh parser.
708
- * @template TStateH The type of the state used by the eighth parser.
709
- * @template TStateI The type of the state used by the ninth parser.
710
- * @template TStateJ The type of the state used by the tenth parser.
711
- * @param a The first {@link Parser} to try.
712
- * @param b The second {@link Parser} to try.
713
- * @param c The third {@link Parser} to try.
714
- * @param d The fourth {@link Parser} to try.
715
- * @param e The fifth {@link Parser} to try.
716
- * @param f The sixth {@link Parser} to try.
717
- * @param g The seventh {@link Parser} to try.
718
- * @param h The eighth {@link Parser} to try.
719
- * @param i The ninth {@link Parser} to try.
720
- * @param j The tenth {@link Parser} to try.
721
- * @return A {@link Parser} that tries to parse using the provided parsers
722
- * in order, returning the result of the first successful parser.
723
- * @since 0.3.0
724
- */
725
- declare function or<TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ, TStateA, TStateB, TStateC, TStateD, TStateE, TStateF, TStateG, TStateH, TStateI, TStateJ>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>, c: Parser<TC, TStateC>, d: Parser<TD, TStateD>, e: Parser<TE, TStateE>, f: Parser<TF, TStateF>, g: Parser<TG, TStateG>, h: Parser<TH, TStateH>, i: Parser<TI, TStateI>, j: Parser<TJ, TStateJ>): Parser<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>]>;
726
- /**
727
- * Creates a parser that combines two mutually exclusive parsers into one,
728
- * selecting the parser that consumes the most tokens.
729
- * The resulting parser will try both parsers and return the result
730
- * of the parser that consumed more input tokens.
731
- * @template TA The type of the value returned by the first parser.
732
- * @template TB The type of the value returned by the second parser.
733
- * @template TStateA The type of the state used by the first parser.
734
- * @template TStateB The type of the state used by the second parser.
735
- * @param a The first {@link Parser} to try.
736
- * @param b The second {@link Parser} to try.
737
- * @returns A {@link Parser} that tries to parse using both parsers
738
- * and returns the result of the parser that consumed more tokens.
739
- * @since 0.3.0
740
- */
741
- declare function longestMatch<TA, TB, TStateA, TStateB>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>): Parser<TA | TB, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>]>;
742
- /**
743
- * Creates a parser that combines three mutually exclusive parsers into one,
744
- * selecting the parser that consumes the most tokens.
745
- * The resulting parser will try all parsers and return the result
746
- * of the parser that consumed the most input tokens.
747
- * @template TA The type of the value returned by the first parser.
748
- * @template TB The type of the value returned by the second parser.
749
- * @template TC The type of the value returned by the third parser.
750
- * @template TStateA The type of the state used by the first parser.
751
- * @template TStateB The type of the state used by the second parser.
752
- * @template TStateC The type of the state used by the third parser.
753
- * @param a The first {@link Parser} to try.
754
- * @param b The second {@link Parser} to try.
755
- * @param c The third {@link Parser} to try.
756
- * @returns A {@link Parser} that tries to parse using all parsers
757
- * and returns the result of the parser that consumed the most tokens.
758
- * @since 0.3.0
759
- */
760
- declare function longestMatch<TA, TB, TC, TStateA, TStateB, TStateC>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>, c: Parser<TC, TStateC>): Parser<TA | TB | TC, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>]>;
761
- /**
762
- * Creates a parser that combines four mutually exclusive parsers into one,
763
- * selecting the parser that consumes the most tokens.
764
- * The resulting parser will try all parsers and return the result
765
- * of the parser that consumed the most input tokens.
766
- * @template TA The type of the value returned by the first parser.
767
- * @template TB The type of the value returned by the second parser.
768
- * @template TC The type of the value returned by the third parser.
769
- * @template TD The type of the value returned by the fourth parser.
770
- * @template TStateA The type of the state used by the first parser.
771
- * @template TStateB The type of the state used by the second parser.
772
- * @template TStateC The type of the state used by the third parser.
773
- * @template TStateD The type of the state used by the fourth parser.
774
- * @param a The first {@link Parser} to try.
775
- * @param b The second {@link Parser} to try.
776
- * @param c The third {@link Parser} to try.
777
- * @param d The fourth {@link Parser} to try.
778
- * @returns A {@link Parser} that tries to parse using all parsers
779
- * and returns the result of the parser that consumed the most tokens.
780
- * @since 0.3.0
781
- */
782
- declare function longestMatch<TA, TB, TC, TD, TStateA, TStateB, TStateC, TStateD>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>, c: Parser<TC, TStateC>, d: Parser<TD, TStateD>): Parser<TA | TB | TC | TD, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>]>;
783
- /**
784
- * Creates a parser that combines five mutually exclusive parsers into one,
785
- * selecting the parser that consumes the most tokens.
786
- * The resulting parser will try all parsers and return the result
787
- * of the parser that consumed the most input tokens.
788
- * @template TA The type of the value returned by the first parser.
789
- * @template TB The type of the value returned by the second parser.
790
- * @template TC The type of the value returned by the third parser.
791
- * @template TD The type of the value returned by the fourth parser.
792
- * @template TE The type of the value returned by the fifth parser.
793
- * @template TStateA The type of the state used by the first parser.
794
- * @template TStateB The type of the state used by the second parser.
795
- * @template TStateC The type of the state used by the third parser.
796
- * @template TStateD The type of the state used by the fourth parser.
797
- * @template TStateE The type of the state used by the fifth parser.
798
- * @param a The first {@link Parser} to try.
799
- * @param b The second {@link Parser} to try.
800
- * @param c The third {@link Parser} to try.
801
- * @param d The fourth {@link Parser} to try.
802
- * @param e The fifth {@link Parser} to try.
803
- * @returns A {@link Parser} that tries to parse using all parsers
804
- * and returns the result of the parser that consumed the most tokens.
805
- * @since 0.3.0
806
- */
807
- declare function longestMatch<TA, TB, TC, TD, TE, TStateA, TStateB, TStateC, TStateD, TStateE>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>, c: Parser<TC, TStateC>, d: Parser<TD, TStateD>, e: Parser<TE, TStateE>): Parser<TA | TB | TC | TD | TE, undefined | [0, ParserResult<TStateA>] | [1, ParserResult<TStateB>] | [2, ParserResult<TStateC>] | [3, ParserResult<TStateD>] | [4, ParserResult<TStateE>]>;
808
- /**
809
- * Helper type to check if all members of a union are object-like.
810
- * This allows merge() to work with parsers like withDefault() that produce union types.
811
- */
812
- type AllObjectLike<T> = T extends readonly unknown[] ? never : T extends Record<string | symbol, unknown> ? T : never;
813
- /**
814
- * Helper type to extract object-like types from parser value types,
815
- * including union types where all members are objects.
816
- */
817
- type ExtractObjectTypes<P> = P extends Parser<infer V, unknown> ? [AllObjectLike<V>] extends [never] ? never : V : never;
818
- /**
819
- * Merges multiple {@link object} parsers into a single {@link object} parser.
820
- * It is useful for combining multiple {@link object} parsers so that
821
- * the unified parser produces a single object containing all the values
822
- * from the individual parsers while separating the fields into multiple
823
- * groups.
824
- * @template TA The type of the first parser.
825
- * @template TB The type of the second parser.
826
- * @param a The first {@link object} parser to merge.
827
- * @param b The second {@link object} parser to merge.
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<unknown, unknown>, TB extends Parser<unknown, unknown>>(a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB): Parser<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<unknown, unknown>, TB extends Parser<unknown, unknown>>(label: string, a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB): Parser<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<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>>(a: ExtractObjectTypes<TA> extends never ? never : TA, b: ExtractObjectTypes<TB> extends never ? never : TB, c: ExtractObjectTypes<TC> extends never ? never : TC): Parser<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<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>>(label: string, a: TA, b: TB, c: TC): ExtractObjectTypes<TA> extends never ? never : ExtractObjectTypes<TB> extends never ? never : ExtractObjectTypes<TC> extends never ? never : Parser<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<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>, TD extends Parser<unknown, unknown>>(a: TA, b: TB, c: TC, d: TD): ExtractObjectTypes<TA> extends never ? never : ExtractObjectTypes<TB> extends never ? never : ExtractObjectTypes<TC> extends never ? never : ExtractObjectTypes<TD> extends never ? never : Parser<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<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>, TD extends Parser<unknown, unknown>>(label: string, a: TA, b: TB, c: TC, d: TD): ExtractObjectTypes<TA> extends never ? never : ExtractObjectTypes<TB> extends never ? never : ExtractObjectTypes<TC> extends never ? never : ExtractObjectTypes<TD> extends never ? never : Parser<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<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>, TD extends Parser<unknown, unknown>, TE extends Parser<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<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<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>, TD extends Parser<unknown, unknown>, TE extends Parser<unknown, unknown>>(label: string, a: TA, b: TB, c: TC, d: TD, e: TE): ExtractObjectTypes<TA> extends never ? never : ExtractObjectTypes<TB> extends never ? never : ExtractObjectTypes<TC> extends never ? never : ExtractObjectTypes<TD> extends never ? never : ExtractObjectTypes<TE> extends never ? never : Parser<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<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>, TD extends Parser<unknown, unknown>, TE extends Parser<unknown, unknown>, TF extends Parser<unknown, unknown>>(a: TA, b: TB, c: TC, d: TD, e: TE, f: TF): ExtractObjectTypes<TA> extends never ? never : ExtractObjectTypes<TB> extends never ? never : ExtractObjectTypes<TC> extends never ? never : ExtractObjectTypes<TD> extends never ? never : ExtractObjectTypes<TE> extends never ? never : ExtractObjectTypes<TF> extends never ? never : Parser<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<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>, TD extends Parser<unknown, unknown>, TE extends Parser<unknown, unknown>, TF extends Parser<unknown, unknown>>(label: string, a: TA, b: TB, c: TC, d: TD, e: TE, f: TF): ExtractObjectTypes<TA> extends never ? never : ExtractObjectTypes<TB> extends never ? never : ExtractObjectTypes<TC> extends never ? never : ExtractObjectTypes<TD> extends never ? never : ExtractObjectTypes<TE> extends never ? never : ExtractObjectTypes<TF> extends never ? never : Parser<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<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>, TD extends Parser<unknown, unknown>, TE extends Parser<unknown, unknown>, TF extends Parser<unknown, unknown>, TG extends Parser<unknown, unknown>>(a: TA, b: TB, c: TC, d: TD, e: TE, f: TF, g: TG): ExtractObjectTypes<TA> extends never ? never : ExtractObjectTypes<TB> extends never ? never : ExtractObjectTypes<TC> extends never ? never : ExtractObjectTypes<TD> extends never ? never : ExtractObjectTypes<TE> extends never ? never : ExtractObjectTypes<TF> extends never ? never : ExtractObjectTypes<TG> extends never ? never : Parser<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<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>, TD extends Parser<unknown, unknown>, TE extends Parser<unknown, unknown>, TF extends Parser<unknown, unknown>, TG extends Parser<unknown, unknown>>(label: string, a: TA, b: TB, c: TC, d: TD, e: TE, f: TF, g: TG): ExtractObjectTypes<TA> extends never ? never : ExtractObjectTypes<TB> extends never ? never : ExtractObjectTypes<TC> extends never ? never : ExtractObjectTypes<TD> extends never ? never : ExtractObjectTypes<TE> extends never ? never : ExtractObjectTypes<TF> extends never ? never : ExtractObjectTypes<TG> extends never ? never : Parser<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<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>, TD extends Parser<unknown, unknown>, TE extends Parser<unknown, unknown>, TF extends Parser<unknown, unknown>, TG extends Parser<unknown, unknown>, TH extends Parser<unknown, unknown>>(a: TA, b: TB, c: TC, d: TD, e: TE, f: TF, g: TG, h: TH): ExtractObjectTypes<TA> extends never ? never : ExtractObjectTypes<TB> extends never ? never : ExtractObjectTypes<TC> extends never ? never : ExtractObjectTypes<TD> extends never ? never : ExtractObjectTypes<TE> extends never ? never : ExtractObjectTypes<TF> extends never ? never : ExtractObjectTypes<TG> extends never ? never : ExtractObjectTypes<TH> extends never ? never : Parser<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<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>, TD extends Parser<unknown, unknown>, TE extends Parser<unknown, unknown>, TF extends Parser<unknown, unknown>, TG extends Parser<unknown, unknown>, TH extends Parser<unknown, unknown>>(label: string, a: TA, b: TB, c: TC, d: TD, e: TE, f: TF, g: TG, h: TH): ExtractObjectTypes<TA> extends never ? never : ExtractObjectTypes<TB> extends never ? never : ExtractObjectTypes<TC> extends never ? never : ExtractObjectTypes<TD> extends never ? never : ExtractObjectTypes<TE> extends never ? never : ExtractObjectTypes<TF> extends never ? never : ExtractObjectTypes<TG> extends never ? never : ExtractObjectTypes<TH> extends never ? never : Parser<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
1152
- */
1153
- declare function merge<TA extends Parser<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>, TD extends Parser<unknown, unknown>, TE extends Parser<unknown, unknown>, TF extends Parser<unknown, unknown>, TG extends Parser<unknown, unknown>, TH extends Parser<unknown, unknown>, TI extends Parser<unknown, unknown>>(a: TA, b: TB, c: TC, d: TD, e: TE, f: TF, g: TG, h: TH, i: TI): ExtractObjectTypes<TA> extends never ? never : ExtractObjectTypes<TB> extends never ? never : ExtractObjectTypes<TC> extends never ? never : ExtractObjectTypes<TD> extends never ? never : ExtractObjectTypes<TE> extends never ? never : ExtractObjectTypes<TF> extends never ? never : ExtractObjectTypes<TG> extends never ? never : ExtractObjectTypes<TH> extends never ? never : ExtractObjectTypes<TI> extends never ? never : Parser<ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE> & ExtractObjectTypes<TF> & ExtractObjectTypes<TG> & ExtractObjectTypes<TH> & ExtractObjectTypes<TI>, Record<string | symbol, unknown>>;
1154
- /**
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.
1183
- * @since 0.4.0
1184
- */
1185
- declare function merge<TA extends Parser<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>, TD extends Parser<unknown, unknown>, TE extends Parser<unknown, unknown>, TF extends Parser<unknown, unknown>, TG extends Parser<unknown, unknown>, TH extends Parser<unknown, unknown>, TI extends Parser<unknown, unknown>>(label: string, a: TA, b: TB, c: TC, d: TD, e: TE, f: TF, g: TG, h: TH, i: TI): ExtractObjectTypes<TA> extends never ? never : ExtractObjectTypes<TB> extends never ? never : ExtractObjectTypes<TC> extends never ? never : ExtractObjectTypes<TD> extends never ? never : ExtractObjectTypes<TE> extends never ? never : ExtractObjectTypes<TF> extends never ? never : ExtractObjectTypes<TG> extends never ? never : ExtractObjectTypes<TH> extends never ? never : ExtractObjectTypes<TI> extends never ? never : Parser<ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE> & ExtractObjectTypes<TF> & ExtractObjectTypes<TG> & ExtractObjectTypes<TH> & ExtractObjectTypes<TI>, Record<string | symbol, unknown>>;
1186
- /**
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
1215
- */
1216
- declare function merge<TA extends Parser<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>, TD extends Parser<unknown, unknown>, TE extends Parser<unknown, unknown>, TF extends Parser<unknown, unknown>, TG extends Parser<unknown, unknown>, TH extends Parser<unknown, unknown>, TI extends Parser<unknown, unknown>, TJ extends Parser<unknown, unknown>>(a: TA, b: TB, c: TC, d: TD, e: TE, f: TF, g: TG, h: TH, i: TI, j: TJ): ExtractObjectTypes<TA> extends never ? never : ExtractObjectTypes<TB> extends never ? never : ExtractObjectTypes<TC> extends never ? never : ExtractObjectTypes<TD> extends never ? never : ExtractObjectTypes<TE> extends never ? never : ExtractObjectTypes<TF> extends never ? never : ExtractObjectTypes<TG> extends never ? never : ExtractObjectTypes<TH> extends never ? never : ExtractObjectTypes<TI> extends never ? never : ExtractObjectTypes<TJ> extends never ? never : Parser<ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE> & ExtractObjectTypes<TF> & ExtractObjectTypes<TG> & ExtractObjectTypes<TH> & ExtractObjectTypes<TI> & ExtractObjectTypes<TJ>, Record<string | symbol, unknown>>;
1217
- /**
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<unknown, unknown>, TB extends Parser<unknown, unknown>, TC extends Parser<unknown, unknown>, TD extends Parser<unknown, unknown>, TE extends Parser<unknown, unknown>, TF extends Parser<unknown, unknown>, TG extends Parser<unknown, unknown>, TH extends Parser<unknown, unknown>, TI extends Parser<unknown, unknown>, TJ extends Parser<unknown, unknown>>(label: string, a: TA, b: TB, c: TC, d: TD, e: TE, f: TF, g: TG, h: TH, i: TI, j: TJ): ExtractObjectTypes<TA> extends never ? never : ExtractObjectTypes<TB> extends never ? never : ExtractObjectTypes<TC> extends never ? never : ExtractObjectTypes<TD> extends never ? never : ExtractObjectTypes<TE> extends never ? never : ExtractObjectTypes<TF> extends never ? never : ExtractObjectTypes<TG> extends never ? never : ExtractObjectTypes<TH> extends never ? never : ExtractObjectTypes<TI> extends never ? never : ExtractObjectTypes<TJ> extends never ? never : Parser<ExtractObjectTypes<TA> & ExtractObjectTypes<TB> & ExtractObjectTypes<TC> & ExtractObjectTypes<TD> & ExtractObjectTypes<TE> & ExtractObjectTypes<TF> & ExtractObjectTypes<TG> & ExtractObjectTypes<TH> & ExtractObjectTypes<TI> & ExtractObjectTypes<TJ>, Record<string | symbol, unknown>>;
1251
- /**
1252
- * Concatenates two {@link tuple} parsers into a single parser that produces
1253
- * a flattened tuple containing the values from both parsers in order.
1254
- *
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.
1258
- *
1259
- * @example
1260
- * ```typescript
1261
- * const basicTuple = tuple([
1262
- * option("-v", "--verbose"),
1263
- * option("-p", "--port", integer()),
1264
- * ]);
1265
- *
1266
- * const serverTuple = tuple([
1267
- * option("-h", "--host", string()),
1268
- * option("-d", "--debug"),
1269
- * ]);
1270
- *
1271
- * const combined = concat(basicTuple, serverTuple);
1272
- * // Type: Parser<[boolean, number, string, boolean], [BasicState, ServerState]>
1273
- *
1274
- * const result = parse(combined, ["-v", "-p", "8080", "-h", "localhost", "-d"]);
1275
- * // result.value: [true, 8080, "localhost", true]
1276
- * ```
1277
- *
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<TA extends readonly unknown[], TB extends readonly unknown[], TStateA, TStateB>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>): Parser<[...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.
1304
- * @since 0.2.0
1305
- */
1306
- declare function concat<TA extends readonly unknown[], TB extends readonly unknown[], TC extends readonly unknown[], TStateA, TStateB, TStateC>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>, c: Parser<TC, TStateC>): Parser<[...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<TA extends readonly unknown[], TB extends readonly unknown[], TC extends readonly unknown[], TD extends readonly unknown[], TStateA, TStateB, TStateC, TStateD>(a: Parser<TA, TStateA>, b: Parser<TB, TStateB>, c: Parser<TC, TStateC>, d: Parser<TD, TStateD>): Parser<[...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<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<TA, TStateA>, b: Parser<TB, TStateB>, c: Parser<TC, TStateC>, d: Parser<TD, TStateD>, e: Parser<TE, TStateE>): Parser<[...TA, ...TB, ...TC, ...TD, ...TE], [TStateA, TStateB, TStateC, TStateD, TStateE]>;
1352
- /**
1353
- * Options for the {@link command} parser.
1354
- */
1355
- interface CommandOptions {
1356
- /**
1357
- * A description of the command, used for documentation.
1358
- */
1359
- readonly description?: Message;
1360
- }
1361
- /**
1362
- * The state type for the {@link command} parser.
1363
- * @template TState The type of the inner parser's state.
1364
- */
1365
- type CommandState<TState> = undefined | ["matched", string] | ["parsing", TState];
1366
- /**
1367
- * Creates a parser that matches a specific subcommand name and then applies
1368
- * an inner parser to the remaining arguments.
1369
- * This is useful for building CLI tools with subcommands like git, npm, etc.
1370
- * @template T The type of the value returned by the inner parser.
1371
- * @template TState The type of the state used by the inner parser.
1372
- * @param name The subcommand name to match (e.g., `"show"`, `"edit"`).
1373
- * @param parser The {@link Parser} to apply after the command is matched.
1374
- * @param options Optional configuration for the command parser, such as
1375
- * a description for documentation.
1376
- * @returns A {@link Parser} that matches the command name and delegates
1377
- * to the inner parser for the remaining arguments.
1378
- */
1379
- declare function command<T, TState>(name: string, parser: Parser<T, TState>, options?: CommandOptions): Parser<T, CommandState<TState>>;
1380
150
  /**
1381
151
  * Infers the result value type of a {@link Parser}.
1382
152
  * @template T The {@link Parser} to infer the result value type from.
@@ -1423,49 +193,6 @@ type Result<T> = {
1423
193
  * failure.
1424
194
  */
1425
195
  declare function parse<T>(parser: Parser<T, unknown>, args: readonly string[]): Result<T>;
1426
- /**
1427
- * Wraps a parser with a group label for documentation purposes.
1428
- *
1429
- * The `group()` function is a documentation-only wrapper that applies a label
1430
- * to any parser for help text organization. This allows you to use clean code
1431
- * structure with combinators like {@link merge} while maintaining well-organized
1432
- * help text through group labeling.
1433
- *
1434
- * The wrapped parser has identical parsing behavior but generates documentation
1435
- * fragments wrapped in a labeled section. This is particularly useful when
1436
- * combining parsers using {@link merge}—you can wrap the merged result with
1437
- * `group()` to add a section header in help output.
1438
- *
1439
- * @example
1440
- * ```typescript
1441
- * const apiOptions = merge(
1442
- * object({ endpoint: option("--endpoint", string()) }),
1443
- * object({ timeout: option("--timeout", integer()) })
1444
- * );
1445
- *
1446
- * const groupedApiOptions = group("API Options", apiOptions);
1447
- * // Now produces a labeled "API Options" section in help text
1448
- * ```
1449
- *
1450
- * @example
1451
- * ```typescript
1452
- * // Can be used with any parser, not just merge()
1453
- * const verboseGroup = group("Verbosity", object({
1454
- * verbose: option("-v", "--verbose"),
1455
- * quiet: option("-q", "--quiet")
1456
- * }));
1457
- * ```
1458
- *
1459
- * @template TValue The value type of the wrapped parser.
1460
- * @template TState The state type of the wrapped parser.
1461
- * @param label A descriptive label for this parser group, used for
1462
- * documentation and help text organization.
1463
- * @param parser The parser to wrap with a group label.
1464
- * @returns A new parser that behaves identically to the input parser
1465
- * but generates documentation within a labeled section.
1466
- * @since 0.4.0
1467
- */
1468
- declare function group<TValue, TState>(label: string, parser: Parser<TValue, TState>): Parser<TValue, TState>;
1469
196
  /**
1470
197
  * Generates a documentation page for a parser based on its current state after
1471
198
  * attempting to parse the provided arguments. This function is useful for
@@ -1501,4 +228,4 @@ declare function group<TValue, TState>(label: string, parser: Parser<TValue, TSt
1501
228
  */
1502
229
  declare function getDocPage(parser: Parser<unknown, unknown>, args?: readonly string[]): DocPage | undefined;
1503
230
  //#endregion
1504
- export { ArgumentOptions, CommandOptions, DocState, FlagOptions, InferValue, MultipleOptions, OptionOptions, Parser, ParserContext, ParserResult, Result, WithDefaultError, WithDefaultOptions, argument, command, concat, constant, flag, getDocPage, group, longestMatch, map, merge, multiple, object, option, optional, or, parse, tuple, withDefault };
231
+ export { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, DocState, FlagErrorOptions, FlagOptions, InferValue, LongestMatchErrorOptions, LongestMatchOptions, MultipleErrorOptions, MultipleOptions, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionOptions, OrErrorOptions, OrOptions, Parser, ParserContext, ParserResult, Result, WithDefaultError, WithDefaultOptions, argument, command, concat, constant, flag, getDocPage, group, longestMatch, map, merge, multiple, object, option, optional, or, parse, tuple, withDefault };