@optique/core 1.0.0-dev.667 → 1.0.0-dev.670

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.
@@ -119,8 +119,11 @@ function formatDefaultChoiceError(input, choices) {
119
119
  * @param options Configuration options for the string parser.
120
120
  * @returns A {@link ValueParser} that parses strings according to the
121
121
  * specified options.
122
+ * @throws {TypeError} If `options.pattern` is provided but is not a
123
+ * `RegExp` instance.
122
124
  */
123
125
  function string(options = {}) {
126
+ if (options.pattern != null && !(options.pattern instanceof RegExp)) throw new TypeError(`Expected pattern to be a RegExp, but got: ${Object.prototype.toString.call(options.pattern)}`);
124
127
  const metavar = options.metavar ?? "STRING";
125
128
  require_nonempty.ensureNonEmptyString(metavar);
126
129
  return {
@@ -235,6 +235,8 @@ declare function choice<const T extends number>(choices: readonly T[], options?:
235
235
  * @param options Configuration options for the string parser.
236
236
  * @returns A {@link ValueParser} that parses strings according to the
237
237
  * specified options.
238
+ * @throws {TypeError} If `options.pattern` is provided but is not a
239
+ * `RegExp` instance.
238
240
  */
239
241
  declare function string(options?: StringOptions): ValueParser<"sync", string>;
240
242
  /**
@@ -235,6 +235,8 @@ declare function choice<const T extends number>(choices: readonly T[], options?:
235
235
  * @param options Configuration options for the string parser.
236
236
  * @returns A {@link ValueParser} that parses strings according to the
237
237
  * specified options.
238
+ * @throws {TypeError} If `options.pattern` is provided but is not a
239
+ * `RegExp` instance.
238
240
  */
239
241
  declare function string(options?: StringOptions): ValueParser<"sync", string>;
240
242
  /**
@@ -119,8 +119,11 @@ function formatDefaultChoiceError(input, choices) {
119
119
  * @param options Configuration options for the string parser.
120
120
  * @returns A {@link ValueParser} that parses strings according to the
121
121
  * specified options.
122
+ * @throws {TypeError} If `options.pattern` is provided but is not a
123
+ * `RegExp` instance.
122
124
  */
123
125
  function string(options = {}) {
126
+ if (options.pattern != null && !(options.pattern instanceof RegExp)) throw new TypeError(`Expected pattern to be a RegExp, but got: ${Object.prototype.toString.call(options.pattern)}`);
124
127
  const metavar = options.metavar ?? "STRING";
125
128
  ensureNonEmptyString(metavar);
126
129
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.667+b4962990",
3
+ "version": "1.0.0-dev.670+a142c6c9",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",