@ptolemy2002/rgx 8.1.0 → 8.2.0

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/README.md CHANGED
@@ -17,6 +17,7 @@ Because there is so much to document, it has been broken up into multiple files.
17
17
  - [escapeRegex](./docs/util/escapeRegex.md) - The `escapeRegex` function, which escapes special regex characters in a given string and assures you that the result is valid Regex.
18
18
  - [regexMatchAtPosition](./docs/util/regexMatchAtPosition.md) - The `regexMatchAtPosition` function and related functions, which attempt to match a given regular expression at a specific position in a string.
19
19
  - [regexWithFlags](./docs/util/regexWithFlags.md) - The `regexWithFlags` function, which creates a new regular expression with the same source as a given regular expression but with different flags.
20
+ - [createRGXClassGuardFunction](./docs/util/createRGXClassGuardFunction.md) - The `createRGXClassGuardFunction` and `createAssertRGXClassGuardFunction` utilities for creating type guard and assertion functions for class instances.
20
21
  - `class` - A directory containing documentation for all classes in the library.
21
22
  - [collection](./docs/class/collection.md) - The `RGXTokenCollection` class, which is a collection of tokens.
22
23
  - [RGXError](./docs/class/RGXError.md) - Details on all custom error classes and the base `RGXError` class.
@@ -4,6 +4,7 @@ exports.rgxGroup = exports.RGXGroupToken = void 0;
4
4
  const collection_1 = require("../collection");
5
5
  const base_1 = require("./base");
6
6
  const internal_1 = require("../internal");
7
+ const utils_1 = require("../utils");
7
8
  const typeGuards_1 = require("../typeGuards");
8
9
  const immutability_utils_1 = require("@ptolemy2002/immutability-utils");
9
10
  class RGXGroupToken extends base_1.RGXClassToken {
@@ -60,6 +61,6 @@ class RGXGroupToken extends base_1.RGXClassToken {
60
61
  }
61
62
  }
62
63
  exports.RGXGroupToken = RGXGroupToken;
63
- RGXGroupToken.check = (0, internal_1.createClassGuardFunction)(RGXGroupToken);
64
- RGXGroupToken.assert = (0, internal_1.createAssertClassGuardFunction)(RGXGroupToken);
64
+ RGXGroupToken.check = (0, utils_1.createRGXClassGuardFunction)(RGXGroupToken);
65
+ RGXGroupToken.assert = (0, utils_1.createAssertRGXClassGuardFunction)(RGXGroupToken);
65
66
  exports.rgxGroup = (0, internal_1.createConstructFunction)(RGXGroupToken);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rgxLookahead = exports.RGXLookaheadToken = void 0;
4
4
  const internal_1 = require("../internal");
5
+ const utils_1 = require("../utils");
5
6
  const lookaround_1 = require("./lookaround");
6
7
  const lookbehind_1 = require("./lookbehind");
7
8
  const immutability_utils_1 = require("@ptolemy2002/immutability-utils");
@@ -27,6 +28,6 @@ class RGXLookaheadToken extends lookaround_1.RGXLookaroundToken {
27
28
  }
28
29
  }
29
30
  exports.RGXLookaheadToken = RGXLookaheadToken;
30
- RGXLookaheadToken.check = (0, internal_1.createClassGuardFunction)(RGXLookaheadToken);
31
- RGXLookaheadToken.assert = (0, internal_1.createAssertClassGuardFunction)(RGXLookaheadToken);
31
+ RGXLookaheadToken.check = (0, utils_1.createRGXClassGuardFunction)(RGXLookaheadToken);
32
+ RGXLookaheadToken.assert = (0, utils_1.createAssertRGXClassGuardFunction)(RGXLookaheadToken);
32
33
  exports.rgxLookahead = (0, internal_1.createConstructFunction)(RGXLookaheadToken);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rgxLookbehind = exports.RGXLookbehindToken = void 0;
4
4
  const internal_1 = require("../internal");
5
+ const utils_1 = require("../utils");
5
6
  const lookahead_1 = require("./lookahead");
6
7
  const lookaround_1 = require("./lookaround");
7
8
  const immutability_utils_1 = require("@ptolemy2002/immutability-utils");
@@ -27,6 +28,6 @@ class RGXLookbehindToken extends lookaround_1.RGXLookaroundToken {
27
28
  }
28
29
  }
29
30
  exports.RGXLookbehindToken = RGXLookbehindToken;
30
- RGXLookbehindToken.check = (0, internal_1.createClassGuardFunction)(RGXLookbehindToken);
31
- RGXLookbehindToken.assert = (0, internal_1.createAssertClassGuardFunction)(RGXLookbehindToken);
31
+ RGXLookbehindToken.check = (0, utils_1.createRGXClassGuardFunction)(RGXLookbehindToken);
32
+ RGXLookbehindToken.assert = (0, utils_1.createAssertRGXClassGuardFunction)(RGXLookbehindToken);
32
33
  exports.rgxLookbehind = (0, internal_1.createConstructFunction)(RGXLookbehindToken);
@@ -7,6 +7,7 @@ const typeGuards_1 = require("../typeGuards");
7
7
  const errors_1 = require("../errors");
8
8
  const resolve_1 = require("../resolve");
9
9
  const internal_1 = require("../internal");
10
+ const utils_1 = require("../utils");
10
11
  const immutability_utils_1 = require("@ptolemy2002/immutability-utils");
11
12
  const clone_1 = require("../clone");
12
13
  class RGXRepeatToken extends base_1.RGXClassToken {
@@ -98,6 +99,6 @@ class RGXRepeatToken extends base_1.RGXClassToken {
98
99
  }
99
100
  }
100
101
  exports.RGXRepeatToken = RGXRepeatToken;
101
- RGXRepeatToken.check = (0, internal_1.createClassGuardFunction)(RGXRepeatToken);
102
- RGXRepeatToken.assert = (0, internal_1.createAssertClassGuardFunction)(RGXRepeatToken);
102
+ RGXRepeatToken.check = (0, utils_1.createRGXClassGuardFunction)(RGXRepeatToken);
103
+ RGXRepeatToken.assert = (0, utils_1.createAssertRGXClassGuardFunction)(RGXRepeatToken);
103
104
  exports.rgxRepeat = (0, internal_1.createConstructFunction)(RGXRepeatToken);
@@ -5,6 +5,7 @@ const base_1 = require("./base");
5
5
  const typeGuards_1 = require("../typeGuards");
6
6
  const errors_1 = require("../errors");
7
7
  const internal_1 = require("../internal");
8
+ const utils_1 = require("../utils");
8
9
  class RGXSubpatternToken extends base_1.RGXClassToken {
9
10
  get pattern() {
10
11
  return this._pattern;
@@ -38,6 +39,6 @@ class RGXSubpatternToken extends base_1.RGXClassToken {
38
39
  }
39
40
  }
40
41
  exports.RGXSubpatternToken = RGXSubpatternToken;
41
- RGXSubpatternToken.check = (0, internal_1.createClassGuardFunction)(RGXSubpatternToken);
42
- RGXSubpatternToken.assert = (0, internal_1.createAssertClassGuardFunction)(RGXSubpatternToken);
42
+ RGXSubpatternToken.check = (0, utils_1.createRGXClassGuardFunction)(RGXSubpatternToken);
43
+ RGXSubpatternToken.assert = (0, utils_1.createAssertRGXClassGuardFunction)(RGXSubpatternToken);
43
44
  exports.rgxSubpattern = (0, internal_1.createConstructFunction)(RGXSubpatternToken);
@@ -7,6 +7,7 @@ const internal_1 = require("../internal");
7
7
  const collection_1 = require("../collection");
8
8
  const base_1 = require("./base");
9
9
  const immutability_utils_1 = require("@ptolemy2002/immutability-utils");
10
+ const utils_1 = require("../utils");
10
11
  class RGXClassUnionToken extends base_1.RGXClassToken {
11
12
  constructor(tokens = []) {
12
13
  super();
@@ -52,8 +53,8 @@ class RGXClassUnionToken extends base_1.RGXClassToken {
52
53
  }
53
54
  }
54
55
  exports.RGXClassUnionToken = RGXClassUnionToken;
55
- RGXClassUnionToken.check = (0, internal_1.createClassGuardFunction)(RGXClassUnionToken);
56
- RGXClassUnionToken.assert = (0, internal_1.createAssertClassGuardFunction)(RGXClassUnionToken);
56
+ RGXClassUnionToken.check = (0, utils_1.createRGXClassGuardFunction)(RGXClassUnionToken);
57
+ RGXClassUnionToken.assert = (0, utils_1.createAssertRGXClassGuardFunction)(RGXClassUnionToken);
57
58
  function expandRgxUnionTokens(...tokens) {
58
59
  const result = new collection_1.RGXTokenCollection();
59
60
  for (const token of tokens) {
@@ -6,6 +6,7 @@ const typeGuards_1 = require("../typeGuards");
6
6
  const internal_1 = require("../internal");
7
7
  const immutability_utils_1 = require("@ptolemy2002/immutability-utils");
8
8
  const clone_1 = require("../clone");
9
+ const utils_1 = require("../utils");
9
10
  class RGXClassWrapperToken extends base_1.RGXClassToken {
10
11
  constructor(token) {
11
12
  super();
@@ -33,6 +34,6 @@ class RGXClassWrapperToken extends base_1.RGXClassToken {
33
34
  }
34
35
  }
35
36
  exports.RGXClassWrapperToken = RGXClassWrapperToken;
36
- RGXClassWrapperToken.check = (0, internal_1.createClassGuardFunction)(RGXClassWrapperToken);
37
- RGXClassWrapperToken.assert = (0, internal_1.createAssertClassGuardFunction)(RGXClassWrapperToken);
37
+ RGXClassWrapperToken.check = (0, utils_1.createRGXClassGuardFunction)(RGXClassWrapperToken);
38
+ RGXClassWrapperToken.assert = (0, utils_1.createAssertRGXClassGuardFunction)(RGXClassWrapperToken);
38
39
  exports.rgxClassWrapper = (0, internal_1.createConstructFunction)(RGXClassWrapperToken);
@@ -5,6 +5,7 @@ const resolve_1 = require("./resolve");
5
5
  const concat_1 = require("./concat");
6
6
  const immutability_utils_1 = require("@ptolemy2002/immutability-utils");
7
7
  const internal_1 = require("./internal");
8
+ const utils_1 = require("./utils");
8
9
  class RGXTokenCollection {
9
10
  constructor(tokens = [], mode = 'concat') {
10
11
  this.tokens = [];
@@ -167,6 +168,6 @@ class RGXTokenCollection {
167
168
  }
168
169
  }
169
170
  exports.RGXTokenCollection = RGXTokenCollection;
170
- RGXTokenCollection.check = (0, internal_1.createClassGuardFunction)(RGXTokenCollection);
171
- RGXTokenCollection.assert = (0, internal_1.createAssertClassGuardFunction)(RGXTokenCollection);
171
+ RGXTokenCollection.check = (0, utils_1.createRGXClassGuardFunction)(RGXTokenCollection);
172
+ RGXTokenCollection.assert = (0, utils_1.createAssertRGXClassGuardFunction)(RGXTokenCollection);
172
173
  exports.rgxTokenCollection = (0, internal_1.createConstructFunction)(RGXTokenCollection);
@@ -1,4 +1,4 @@
1
- export type RGXErrorCode = 'UNKNOWN' | 'INVALID_RGX_TOKEN' | 'INVALID_REGEX_STRING' | 'INVALID_REGEX_FLAGS' | 'INVALID_VANILLA_REGEX_FLAGS' | 'NOT_IMPLEMENTED' | 'NOT_SUPPORTED' | 'INVALID_IDENTIFIER' | 'OUT_OF_BOUNDS' | 'INVALID_FLAG_TRANSFORMER_KEY' | 'FLAG_TRANSFORMER_CONFLICT' | 'CONSTANT_CONFLICT' | 'INVALID_CONSTANT_KEY' | 'INSERTION_REJECTED' | 'REGEX_NOT_MATCHED_AT_POSITION' | 'PART_VALIDATION_FAILED' | 'INVALID_LEXER_MODE' | 'LEXEME_NOT_MATCHED_AT_POSITION' | 'INVALID_RGX_LEXER';
1
+ export type RGXErrorCode = 'UNKNOWN' | 'INVALID_RGX_TOKEN' | 'INVALID_REGEX_STRING' | 'INVALID_REGEX_FLAGS' | 'INVALID_VANILLA_REGEX_FLAGS' | 'NOT_IMPLEMENTED' | 'NOT_SUPPORTED' | 'INVALID_IDENTIFIER' | 'OUT_OF_BOUNDS' | 'INVALID_FLAG_TRANSFORMER_KEY' | 'FLAG_TRANSFORMER_CONFLICT' | 'CONSTANT_CONFLICT' | 'INVALID_CONSTANT_KEY' | 'INSERTION_REJECTED' | 'REGEX_NOT_MATCHED_AT_POSITION' | 'PART_VALIDATION_FAILED' | 'INVALID_LEXER_MODE' | 'LEXEME_NOT_MATCHED_AT_POSITION' | 'INVALID_RGX_LEXER' | 'INVALID_RGX_WALKER' | 'INVALID_RGX_PART';
2
2
  export declare class RGXError extends Error {
3
3
  _message: string;
4
4
  code: RGXErrorCode;
@@ -17,3 +17,5 @@ export * from './partValidationFailed';
17
17
  export * from './invalidLexerMode';
18
18
  export * from './lexemeNotMatchedAtPosition';
19
19
  export * from './invalidLexer';
20
+ export * from './invalidWalker';
21
+ export * from './invalidPart';
@@ -33,3 +33,5 @@ __exportStar(require("./partValidationFailed"), exports);
33
33
  __exportStar(require("./invalidLexerMode"), exports);
34
34
  __exportStar(require("./lexemeNotMatchedAtPosition"), exports);
35
35
  __exportStar(require("./invalidLexer"), exports);
36
+ __exportStar(require("./invalidWalker"), exports);
37
+ __exportStar(require("./invalidPart"), exports);
@@ -0,0 +1,7 @@
1
+ import { RGXError } from "./";
2
+ export declare class RGXInvalidPartError extends RGXError {
3
+ constructorName: string;
4
+ got: unknown;
5
+ constructor(message: string, got: unknown, constructorName?: string);
6
+ calcMessage(message: string): string;
7
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RGXInvalidPartError = void 0;
4
+ const errors_1 = require("./");
5
+ const class_1 = require("../class");
6
+ class RGXInvalidPartError extends errors_1.RGXError {
7
+ constructor(message, got, constructorName = "RGXPart") {
8
+ super(message, 'INVALID_RGX_PART');
9
+ this.name = 'RGXInvalidPartError';
10
+ this.got = got;
11
+ this.constructorName = constructorName;
12
+ }
13
+ calcMessage(message) {
14
+ const gotString = class_1.RGXClassToken.check(this.got) ? `instance of ${this.got.constructor.name}` : JSON.stringify(this.got);
15
+ return `${message}; Expected: [instance of ${this.constructorName}]; Got: [${gotString}]`;
16
+ }
17
+ }
18
+ exports.RGXInvalidPartError = RGXInvalidPartError;
@@ -0,0 +1,7 @@
1
+ import { RGXError } from "./";
2
+ export declare class RGXInvalidWalkerError extends RGXError {
3
+ constructorName: string;
4
+ got: unknown;
5
+ constructor(message: string, got: unknown, constructorName?: string);
6
+ calcMessage(message: string): string;
7
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RGXInvalidWalkerError = void 0;
4
+ const errors_1 = require("./");
5
+ const class_1 = require("../class");
6
+ class RGXInvalidWalkerError extends errors_1.RGXError {
7
+ constructor(message, got, constructorName = "RGXWalker") {
8
+ super(message, 'INVALID_RGX_WALKER');
9
+ this.name = 'RGXInvalidWalkerError';
10
+ this.got = got;
11
+ this.constructorName = constructorName;
12
+ }
13
+ calcMessage(message) {
14
+ const gotString = class_1.RGXClassToken.check(this.got) ? `instance of ${this.got.constructor.name}` : JSON.stringify(this.got);
15
+ return `${message}; Expected: [instance of ${this.constructorName}]; Got: [${gotString}]`;
16
+ }
17
+ }
18
+ exports.RGXInvalidWalkerError = RGXInvalidWalkerError;
@@ -1,5 +1,4 @@
1
1
  export * from "./createConstructFunction";
2
- export * from "./createClassGuardFunction";
3
2
  export * from "./taggedTemplateToArray";
4
3
  export * from "./isConstructor";
5
4
  export * from "./getProxy";
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./createConstructFunction"), exports);
18
- __exportStar(require("./createClassGuardFunction"), exports);
19
18
  __exportStar(require("./taggedTemplateToArray"), exports);
20
19
  __exportStar(require("./isConstructor"), exports);
21
20
  __exportStar(require("./getProxy"), exports);
@@ -6,7 +6,7 @@ const resolve_1 = require("../resolve");
6
6
  const errors_1 = require("../errors");
7
7
  const walker_1 = require("../walker");
8
8
  const utils_1 = require("../utils");
9
- const internal_1 = require("../internal");
9
+ const utils_2 = require("../utils");
10
10
  const constants_1 = require("../constants");
11
11
  function rgxLexemeLocationFromIndex(source, index) {
12
12
  (0, errors_1.assertInRange)(index, { min: 0, max: source.length }, "index is outside the bounds of the source string");
@@ -192,7 +192,7 @@ class RGXLexer {
192
192
  }
193
193
  }
194
194
  exports.RGXLexer = RGXLexer;
195
- RGXLexer.check = (0, internal_1.createClassGuardFunction)(RGXLexer);
196
- RGXLexer.assert = (0, internal_1.createAssertClassGuardFunction)(RGXLexer, (value, c) => new errors_1.RGXInvalidLexerError("Invalid Lexer", value, c.name));
195
+ RGXLexer.check = (0, utils_2.createRGXClassGuardFunction)(RGXLexer);
196
+ RGXLexer.assert = (0, utils_2.createAssertRGXClassGuardFunction)(RGXLexer, (value, c) => new errors_1.RGXInvalidLexerError("Invalid Lexer", value, c.name));
197
197
  const rgxLexer = (...args) => new RGXLexer(...args);
198
198
  exports.rgxLexer = rgxLexer;
@@ -0,0 +1,3 @@
1
+ import { RGXError } from "../errors";
2
+ export declare function createRGXClassGuardFunction<T extends new (...args: unknown[]) => unknown>(constructor: T): (value: unknown) => value is InstanceType<T>;
3
+ export declare function createAssertRGXClassGuardFunction<T extends new (...args: unknown[]) => unknown>(constructor: T, constructError?: (value: unknown, constructor: T) => RGXError): (value: unknown) => asserts value is InstanceType<T>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createRGXClassGuardFunction = createRGXClassGuardFunction;
4
+ exports.createAssertRGXClassGuardFunction = createAssertRGXClassGuardFunction;
5
+ const errors_1 = require("../errors");
6
+ function createRGXClassGuardFunction(constructor) {
7
+ return (value) => value instanceof constructor;
8
+ }
9
+ function createAssertRGXClassGuardFunction(constructor, constructError = (value, constructor) => new errors_1.RGXInvalidTokenError("Invalid token type", { type: "custom", values: [`instance of ${constructor.name}`] }, value)) {
10
+ return (value) => {
11
+ if (!(value instanceof constructor)) {
12
+ throw constructError(value, constructor);
13
+ }
14
+ };
15
+ }
@@ -1,3 +1,4 @@
1
1
  export * from "./regexMatchAtPosition";
2
2
  export * from "./regexWithFlags";
3
3
  export * from "./normalizeRegexFlags";
4
+ export * from "./createRGXClassGuardFunction";
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./regexMatchAtPosition"), exports);
18
18
  __exportStar(require("./regexWithFlags"), exports);
19
19
  __exportStar(require("./normalizeRegexFlags"), exports);
20
+ __exportStar(require("./createRGXClassGuardFunction"), exports);
@@ -10,7 +10,7 @@ const resolve_1 = require("../resolve");
10
10
  const utils_1 = require("../utils");
11
11
  const typeGuards_1 = require("../typeGuards");
12
12
  const class_1 = require("../class");
13
- const internal_1 = require("../internal");
13
+ const utils_2 = require("../utils");
14
14
  function createBranchGroups(tokens) {
15
15
  if ((tokens instanceof collection_1.RGXTokenCollection && tokens.mode === "union") ||
16
16
  class_1.RGXClassUnionToken.check(tokens))
@@ -214,8 +214,8 @@ class RGXWalker {
214
214
  }
215
215
  }
216
216
  exports.RGXWalker = RGXWalker;
217
- RGXWalker.check = (0, internal_1.createClassGuardFunction)(RGXWalker);
218
- RGXWalker.assert = (0, internal_1.createAssertClassGuardFunction)(RGXWalker);
217
+ RGXWalker.check = (0, utils_2.createRGXClassGuardFunction)(RGXWalker);
218
+ RGXWalker.assert = (0, utils_2.createAssertRGXClassGuardFunction)(RGXWalker, (value, constructor) => new errors_1.RGXInvalidWalkerError("Invalid Walker", value, constructor.name));
219
219
  function rgxWalker(...args) {
220
220
  return new RGXWalker(...args);
221
221
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RGXPart = void 0;
4
4
  exports.rgxPart = rgxPart;
5
- const internal_1 = require("../internal");
5
+ const utils_1 = require("../utils");
6
6
  const clone_1 = require("../clone");
7
7
  const immutability_utils_1 = require("@ptolemy2002/immutability-utils");
8
8
  const errors_1 = require("../errors");
@@ -40,8 +40,8 @@ class RGXPart {
40
40
  }
41
41
  }
42
42
  exports.RGXPart = RGXPart;
43
- RGXPart.check = (0, internal_1.createClassGuardFunction)(RGXPart);
44
- RGXPart.assert = (0, internal_1.createAssertClassGuardFunction)(RGXPart);
43
+ RGXPart.check = (0, utils_1.createRGXClassGuardFunction)(RGXPart);
44
+ RGXPart.assert = (0, utils_1.createAssertRGXClassGuardFunction)(RGXPart, (value, constructor) => new errors_1.RGXInvalidPartError("Invalid Part", value, constructor.name));
45
45
  function rgxPart(...args) {
46
46
  return new RGXPart(...args);
47
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptolemy2002/rgx",
3
- "version": "8.1.0",
3
+ "version": "8.2.0",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,3 +0,0 @@
1
- import { RGXError } from "../errors";
2
- export declare function createClassGuardFunction<T extends new (...args: unknown[]) => unknown>(constructor: T): (value: unknown) => value is InstanceType<T>;
3
- export declare function createAssertClassGuardFunction<T extends new (...args: unknown[]) => unknown>(constructor: T, constructError?: (value: unknown, constructor: T) => RGXError): (value: unknown) => asserts value is InstanceType<T>;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createClassGuardFunction = createClassGuardFunction;
4
- exports.createAssertClassGuardFunction = createAssertClassGuardFunction;
5
- const errors_1 = require("../errors");
6
- function createClassGuardFunction(constructor) {
7
- return (value) => value instanceof constructor;
8
- }
9
- function createAssertClassGuardFunction(constructor, constructError = (value, constructor) => new errors_1.RGXInvalidTokenError("Invalid token type", { type: "custom", values: [`instance of ${constructor.name}`] }, value)) {
10
- return (value) => {
11
- if (!(value instanceof constructor)) {
12
- throw constructError(value, constructor);
13
- }
14
- };
15
- }