@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.
- package/dist/valueparser.cjs +3 -0
- package/dist/valueparser.d.cts +2 -0
- package/dist/valueparser.d.ts +2 -0
- package/dist/valueparser.js +3 -0
- package/package.json +1 -1
package/dist/valueparser.cjs
CHANGED
|
@@ -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 {
|
package/dist/valueparser.d.cts
CHANGED
|
@@ -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
|
/**
|
package/dist/valueparser.d.ts
CHANGED
|
@@ -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
|
/**
|
package/dist/valueparser.js
CHANGED
|
@@ -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 {
|