@ptolemy2002/rgx 4.10.0 → 5.0.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
@@ -1,19 +1,23 @@
1
1
  # RGX
2
2
  A library for easy construction and validation of regular expressions in TypeScript. You can use `rgx` to concatenate various types of tokens into a valid regular expression string, with type safety and validation.
3
3
 
4
+ **Note**: This library is tested with nearly 100% coverage, but any override of `RGXClassToken.clone()` does not have the depth parameter fully tested, as that is ultimately part of `@ptolemy2002/immutability-utils`, which is tested, and setting up tests for that functionality is exceedingly complex.
5
+
4
6
  ## Type Reference
5
7
  ```typescript
6
8
  import { Branded } from "@ptolemy2002/ts-brand-utils";
9
+ import { CloneDepth } from "@ptolemy2002/immutability-utils";
10
+ // type CloneDepth = number | "max";
7
11
 
8
12
  type RGXNoOpToken = null | undefined;
9
13
  type RGXLiteralToken = RegExp;
10
14
  type RGXNativeToken = string | number | boolean | RGXNoOpToken;
11
- type RGXConvertibleToken = { toRgx: () => RGXToken, readonly rgxGroupWrap?: boolean };
15
+ type RGXConvertibleToken = { toRgx: () => RGXToken, readonly rgxGroupWrap?: boolean, readonly rgxIsGroup?: boolean, readonly rgxIsRepeatable?: boolean };
12
16
  type RGXToken = RGXNativeToken | RGXLiteralToken | RGXConvertibleToken | RGXToken[];
13
17
 
14
18
  type RGXClassTokenConstructor = new (...args: unknown[]) => RGXClassToken;
15
- type RGXGroupedToken = RGXToken[] | RGXLiteralToken | (RGXClassToken & { isGroup: true }) | RGXGroupedConvertibleToken;
16
- type RGXGroupedConvertibleToken = { toRgx: () => RGXGroupedToken, readonly rgxGroupWrap: true };
19
+ type RGXGroupedToken = RGXToken[] | RGXLiteralToken | RGXGroupedConvertibleToken;
20
+ type RGXGroupedConvertibleToken = (RGXConvertibleToken & { readonly rgxIsGroup: true }) | (Omit<RGXConvertibleToken, "toRGX"> & { toRgx: () => RGXGroupedToken, readonly rgxGroupWrap: true });
17
21
 
18
22
  const validRegexSymbol = Symbol('rgx.ValidRegex');
19
23
  type ValidRegexBrandSymbol = typeof validRegexSymbol;
@@ -35,7 +39,7 @@ type ValidIdentifier = Branded<string, [ValidIdentifierBrandSymbol]>;
35
39
 
36
40
  type RGXTokenType = 'no-op' | 'literal' | 'native' | 'convertible' | 'class' | RGXTokenType[];
37
41
  type RGXTokenTypeFlat = Exclude<RGXTokenType, RGXTokenType[]> | "array";
38
- type RGXTokenTypeGuardInput = RGXTokenTypeFlat | null | RGXClassTokenConstructor | typeof ExtRegExp | typeof RGXTokenCollection | RGXTokenTypeGuardInput[];
42
+ type RGXTokenTypeGuardInput = RGXTokenTypeFlat | null | RGXClassTokenConstructor | typeof RegExp | typeof ExtRegExp | typeof RGXTokenCollection | RGXTokenTypeGuardInput[];
39
43
  type RGXTokenFromType<T extends RGXTokenTypeGuardInput> =
40
44
  // Maps token type strings to their corresponding types, e.g.:
41
45
  // 'no-op' -> RGXNoOpToken, 'literal' -> RGXLiteralToken, etc.
@@ -253,7 +257,7 @@ constructor(tokens: RGXTokenCollectionInput = [], mode: RGXTokenCollectionMode =
253
257
  - `toRgx() => RegExp`: A method that resolves the collection to a `RegExp` object based on the collection mode. In 'union' mode, the tokens are resolved as alternatives (using the `|` operator), while in 'concat' mode, the tokens are resolved as concatenated together. No flags are applied to the resulting `RegExp`. Since this method returns a `RegExp` (which is `RGXLiteralToken`), `RGXTokenCollection` instances satisfy the `RGXConvertibleToken` interface and can be used directly as tokens in `rgx`, `rgxa`, and other token-accepting functions.
254
258
  - `getTokens() => RGXToken[]`: A method that returns a copy of the array of RGX tokens managed by the collection. This is used to prevent external mutation of the internal `tokens` array.
255
259
  - `toArray() => RGXToken[]`: An alias for `getTokens()`, provided for convenience.
256
- - `clone() => RGXTokenCollection`: A method that creates and returns a deep clone of the RGXTokenCollection instance. This is useful for creating a new collection with the same tokens and mode without affecting the original collection.
260
+ - `clone(depth: CloneDepth = "max") => RGXTokenCollection`: A method that creates and returns a deep clone of the RGXTokenCollection instance. This is useful for creating a new collection with the same tokens and mode without affecting the original collection. The `depth` parameter controls how deeply nested collections are cloned: `0` for no clone, `1` for a shallow clone of the top-level collection, any other number for that many levels down, and `"max"` (the default) for a full deep clone.
257
261
  - `asConcat() => RGXTokenCollection`: If this collection is in 'union' mode, this method returns a new RGXTokenCollection instance with the same tokens but in 'concat' mode. If the collection is already in 'concat' mode, it simply returns itself.
258
262
  - `asUnion() => RGXTokenCollection`: If this collection is in 'concat' mode, this method returns a new RGXTokenCollection instance with the same tokens but in 'union' mode. If the collection is already in 'union' mode, it simply returns itself.
259
263
 
@@ -272,17 +276,18 @@ An abstract base class for creating custom RGX token classes. Subclasses must im
272
276
 
273
277
  #### Abstract Methods
274
278
  - `toRgx() => RGXToken`: Must be implemented by subclasses to return the token's regex representation as any valid RGX token (native, literal, convertible, or array of tokens).
279
+ - `clone(depth: CloneDepth = "max") => RGXClassToken`: Must be implemented by subclasses to return a deep clone of the token instance. The `depth` parameter controls how deeply nested tokens are cloned: `0` for no clone, `1` for a shallow clone of the top-level token, any other number for that many levels down, and `"max"` (the default) for a full deep clone.
275
280
 
276
281
  #### Properties
277
- - `isGroup` (`boolean`): Returns `false` by default. Subclasses can override this to indicate whether the token represents a group.
278
- - `isRepeatable` (`boolean`): Returns `true` by default. Subclasses can override this to indicate that the token cannot be wrapped in an `RGXRepeatToken`. When `false`, attempting to set this token as the `token` property of an `RGXRepeatToken` (including via `repeat()` or `optional()`) will throw an `RGXNotSupportedError`.
282
+ - `rgxIsGroup` (`boolean`): Returns `false` by default. Subclasses can override this to indicate whether the token represents a group.
283
+ - `rgxIsRepeatable` (`boolean`): Returns `true` by default. Subclasses can override this to indicate that the token cannot be wrapped in an `RGXRepeatToken`. When `false`, attempting to set this token as the `token` property of an `RGXRepeatToken` (including via `repeat()` or `optional()`) will throw an `RGXNotSupportedError`.
279
284
  - `rgxGroupWrap` (`boolean`): Returns `true` by default. Controls whether the resolver wraps this token's resolved output in a non-capturing group. Subclasses can override this to prevent double-wrapping (e.g., when the token already wraps itself in a group).
280
285
 
281
286
  #### Methods
282
287
  - `or(...others: RGXTokenCollectionInput[]) => RGXClassUnionToken`: Creates an `RGXClassUnionToken` that represents a union (alternation) of this token with the provided others. If any of the `others` are `RGXClassUnionToken` instances, their tokens are flattened into the union rather than nested. If `this` is already an `RGXClassUnionToken`, its existing tokens are preserved and the others are appended.
283
288
  - `group(args?: RGXGroupTokenArgs) => RGXGroupToken`: Wraps this token in an `RGXGroupToken` with the provided arguments. The `args` parameter defaults to `{}`, which creates a capturing group with no name. This is a convenience method that creates a new `RGXGroupToken` with `this` as the sole token.
284
- - `repeat(min?: number, max?: number | null) => RGXRepeatToken`: Wraps this token in an `RGXRepeatToken` with the given repetition bounds. `min` defaults to `1`, `max` defaults to `min`. Pass `null` for `max` to allow unlimited repetitions. This is a convenience method that creates a new `RGXRepeatToken` with `this` as the token. Throws `RGXNotSupportedError` if called on an `RGXLookaroundToken`, as lookaround assertions cannot be repeated.
285
- - `optional() => RGXRepeatToken`: Shorthand for `repeat(0, 1)`. Wraps this token in an `RGXRepeatToken` that matches the token zero or one times. Throws `RGXNotSupportedError` if called on an `RGXLookaroundToken`, as lookaround assertions cannot be made optional.
289
+ - `repeat(min?: number, max?: number | null) => RGXRepeatToken`: Wraps this token in an `RGXRepeatToken` with the given repetition bounds. `min` defaults to `1`, `max` defaults to `min`. Pass `null` for `max` to allow unlimited repetitions. This is a convenience method that creates a new `RGXRepeatToken` with `this` as the token. Throws `RGXNotSupportedError` if called on a token with `rgxIsRepeatable` set to `false` (e.g., `RGXLookaroundToken`).
290
+ - `optional() => RGXRepeatToken`: Shorthand for `repeat(0, 1)`. Wraps this token in an `RGXRepeatToken` that matches the token zero or one times. Throws `RGXNotSupportedError` if called on a token with `rgxIsRepeatable` set to `false` (e.g., `RGXLookaroundToken`).
286
291
  - `asLookahead(positive?: boolean) => RGXLookaheadToken`: Wraps this token in an `RGXLookaheadToken`. `positive` defaults to `true`. If this token is already an `RGXLookaheadToken`, it is returned as-is without re-wrapping.
287
292
  - `asLookbehind(positive?: boolean) => RGXLookbehindToken`: Wraps this token in an `RGXLookbehindToken`. `positive` defaults to `true`. If this token is already an `RGXLookbehindToken`, it is returned as-is without re-wrapping.
288
293
  - `resolve() => ValidRegexString`: A convenience method that resolves this token by calling `resolveRGXToken(this)`, returning the resolved regex string representation. Since this method is defined on `RGXClassToken`, it is available on all subclasses including `RGXClassUnionToken`, `RGXGroupToken`, `RGXRepeatToken`, and `RGXLookaroundToken`.
@@ -332,7 +337,7 @@ constructor(args?: RGXGroupTokenArgs, tokens?: RGXTokenCollectionInput)
332
337
  - `tokens` (`RGXTokenCollection`): The internal collection of tokens managed in 'concat' mode.
333
338
  - `name` (`string | null`): The name of the group. Setting this to a non-null value validates it as a valid identifier via `assertValidIdentifier`.
334
339
  - `capturing` (`boolean`): Whether the group is capturing. Any named group is automatically capturing (returns `true` when `name` is not `null`). Setting this to `false` also clears `name` to `null`.
335
- - `isGroup` (`true`): Returns `true` as a constant, indicating this token represents a group.
340
+ - `rgxIsGroup` (`true`): Returns `true` as a constant, indicating this token represents a group.
336
341
  - `rgxGroupWrap` (`false`): Returns `false` as a constant, since the group already wraps itself, preventing the resolver from double-wrapping.
337
342
 
338
343
  #### Methods
@@ -356,7 +361,7 @@ constructor(token: RGXToken, min?: number, max?: number | null)
356
361
  - `max` (`number | null`, optional): The maximum number of repetitions. Must be >= `min` when not `null`. Non-integer values are floored. Pass `null` for unlimited repetitions. Defaults to `min`.
357
362
 
358
363
  #### Properties
359
- - `token` (`RGXGroupedToken`): The token being repeated. Setting this will throw `RGXNotSupportedError` if the value is a class token with `isRepeatable` set to `false`, and will automatically wrap non-grouped tokens in a non-capturing `RGXGroupToken`.
364
+ - `token` (`RGXGroupedToken`): The token being repeated. Setting this will throw `RGXNotSupportedError` if the value is a convertible token with `rgxIsRepeatable` set to `false`, and will automatically wrap non-grouped tokens in a non-capturing `RGXGroupToken`.
360
365
  - `min` (`number`): The minimum number of repetitions. Setting this validates that the value is >= 0 and <= `max` (when `max` is not `null`), and floors non-integer values. Throws `RGXOutOfBoundsError` if validation fails.
361
366
  - `max` (`number | null`): The maximum number of repetitions. Setting this validates that the value is >= `min` when not `null`, and floors non-integer values. Pass `null` for unlimited. Throws `RGXOutOfBoundsError` if validation fails.
362
367
  - `repeaterSuffix` (`string`): Returns the regex quantifier suffix based on the current `min` and `max` values: `*` for `{0,}`, `+` for `{1,}`, `?` for `{0,1}`, `{n}` for exact repetitions, `{n,}` for minimum-only, `{n,m}` for a range, or an empty string for `{1,1}` (exactly once, no quantifier needed).
@@ -383,8 +388,8 @@ constructor(tokens?: RGXTokenCollectionInput, positive?: boolean)
383
388
  - `tokens` (`RGXTokenCollection`): The internal collection of tokens managed in 'concat' mode.
384
389
  - `positive` (`boolean`): Whether the lookaround is positive. Setting this updates `negative` accordingly.
385
390
  - `negative` (`boolean`): Whether the lookaround is negative. Setting this updates `positive` accordingly.
386
- - `isGroup` (`true`): Returns `true` as a constant, indicating this token represents a group.
387
- - `isRepeatable` (`false`): Returns `false` as a constant, since lookaround assertions cannot be repeated.
391
+ - `rgxIsGroup` (`true`): Returns `true` as a constant, indicating this token represents a group.
392
+ - `rgxIsRepeatable` (`false`): Returns `false` as a constant, since lookaround assertions cannot be repeated.
388
393
  - `rgxGroupWrap` (`false`): Returns `false` as a constant, since the lookaround already wraps itself in a group.
389
394
 
390
395
  #### Abstract Methods
@@ -420,7 +425,7 @@ A function `rgxLookbehind` is provided with the same parameters as this class' c
420
425
  - `toRgx() => RegExp`: Resolves the lookbehind to a `RegExp`. Positive lookbehinds produce `(?<=...)` and negative lookbehinds produce `(?<!...)`.
421
426
 
422
427
  ### RGXClassWrapperToken extends RGXClassToken
423
- A class that wraps any `RGXToken` as an `RGXClassToken`, giving you access to the extended API class tokens provide. It delegates `isGroup` and `isRepeatable` to the wrapped token where possible.
428
+ A class that wraps any `RGXToken` as an `RGXClassToken`, giving you access to the extended API class tokens provide. It delegates `rgxIsGroup` and `rgxIsRepeatable` to the wrapped token where possible.
424
429
 
425
430
  A function `rgxClassWrapper` is provided with the same parameters as this class' constructor, for easier instantiation without needing to use the `new` keyword.
426
431
 
@@ -436,8 +441,8 @@ constructor(token: RGXToken)
436
441
 
437
442
  #### Properties
438
443
  - `token` (`RGXToken`): The wrapped token.
439
- - `isGroup` (`boolean`): Delegates to the wrapped token's group status via `isRGXGroupedToken`. Returns `true` if the wrapped token is a grouped token, otherwise `false`.
440
- - `isRepeatable` (`boolean`): If the wrapped token is an `RGXClassToken`, delegates to its `isRepeatable` property. Otherwise, returns `true`.
444
+ - `rgxIsGroup` (`boolean`): Delegates to the wrapped token's group status via `isRGXGroupedToken`. Returns `true` if the wrapped token is a grouped token, otherwise `false`.
445
+ - `rgxIsRepeatable` (`boolean`): If the wrapped token is an `RGXClassToken`, delegates to its `rgxIsRepeatable` property. Otherwise, returns `true`.
441
446
 
442
447
  #### Methods
443
448
  - `unwrap() => RGXToken`: Returns the original wrapped token.
@@ -547,7 +552,7 @@ Asserts that the given value is a native token (string, number, boolean, or no-o
547
552
  function isRGXConvertibleToken(value: unknown, returnCheck?: boolean): value is RGXConvertibleToken
548
553
  ```
549
554
 
550
- Checks if the given value is a convertible token (an object with a `toRgx` method). If the `rgxGroupWrap` property is present, it must be a boolean; otherwise, the check fails. When `returnCheck` is `true` (the default), also validates that `toRgx` is callable and returns a valid `RGXToken` (which can be any RGX token type, including other convertible tokens, allowing for recursive structures).
555
+ Checks if the given value is a convertible token (an object with a `toRgx` method). If the `rgxGroupWrap`, `rgxIsRepeatable`, or `rgxIsGroup` properties are present, they must be booleans; otherwise, the check fails. When `returnCheck` is `true` (the default), also validates that `toRgx` is callable and returns a valid `RGXToken` (which can be any RGX token type, including other convertible tokens, allowing for recursive structures).
551
556
 
552
557
  #### Parameters
553
558
  - `value` (`unknown`): The value to check.
@@ -560,7 +565,7 @@ Checks if the given value is a convertible token (an object with a `toRgx` metho
560
565
  ```typescript
561
566
  function assertRGXConvertibleToken(value: unknown, returnCheck?: boolean): asserts value is RGXConvertibleToken
562
567
  ```
563
- Asserts that the given value is a convertible token (an object with a `toRgx` method). If the `rgxGroupWrap` property is present, it must be a boolean; otherwise, the assertion fails. When `returnCheck` is `true` (the default), also validates that `toRgx` is callable and returns a valid `RGXToken` (which can be any RGX token type, including other convertible tokens, allowing for recursive structures). If the assertion fails, an `RGXInvalidTokenError` will be thrown.
568
+ Asserts that the given value is a convertible token (an object with a `toRgx` method). If the `rgxGroupWrap`, `rgxIsRepeatable`, or `rgxIsGroup` properties are present, they must be booleans; otherwise, the assertion fails. When `returnCheck` is `true` (the default), also validates that `toRgx` is callable and returns a valid `RGXToken` (which can be any RGX token type, including other convertible tokens, allowing for recursive structures). If the assertion fails, an `RGXInvalidTokenError` will be thrown.
564
569
 
565
570
  #### Parameters
566
571
  - `value` (`unknown`): The value to assert.
@@ -696,7 +701,7 @@ function isRGXToken<T extends RGXTokenTypeGuardInput = null>(value: unknown, typ
696
701
 
697
702
  Checks if the given value is a valid RGX token, optionally narrowed to a specific token type. When `type` is `null` (the default), it checks against all token types. When `type` is a specific token type string, it checks only against that type. The `'class'` type matches `RGXClassToken` instances specifically, while `'convertible'` also matches class tokens since they implement the convertible interface.
698
703
 
699
- When `type` is an `RGXClassTokenConstructor` (a constructor for an `RGXClassToken` subclass), it performs an `instanceof` check against that specific constructor, allowing you to narrow to a specific class token subclass rather than all class tokens. In this case, `RGXTokenFromType` resolves to `InstanceType<T>`, giving you the specific subclass type.
704
+ When `type` is a constructor, it performs an `instanceof` check against that specific constructor, allowing you to narrow to a specific class token subclass rather than all class tokens. In this case, `RGXTokenFromType` resolves to `InstanceType<T>`, giving you the specific subclass type.
700
705
 
701
706
  When `type` is an array, it checks that every element of the value array is a valid RGX token matching the corresponding type in the `type` array. If `matchLength` is `true` (the default), it also requires that the value array has the same length as the type array; if `false`, it allows the value array to be longer than the type array, as long as all elements up to the length of the type array match and all elements after that are still valid RGX tokens of any type.
702
707
 
@@ -728,11 +733,11 @@ Asserts that the given value is a valid RGX token, optionally narrowed to a spec
728
733
  function isRGXGroupedToken(value: unknown, contentCheck?: boolean): value is RGXGroupedToken
729
734
  ```
730
735
 
731
- Checks if the given value is a grouped token — a token that is implicitly or explicitly a group. Arrays and literal tokens (`RegExp`) are implicitly groups. Class tokens are only groups if they have the `isGroup` property set to `true`. Convertible tokens are groups if they have `rgxGroupWrap` set to `true` and their `toRgx()` method returns a grouped token.
736
+ Checks if the given value is a grouped token — a token that is implicitly or explicitly a group. Arrays and literal tokens (`RegExp`) are implicitly groups. Convertible tokens (including class tokens) are groups if they have `rgxIsGroup` set to `true`, or if they have `rgxGroupWrap` set to `true` and their `toRgx()` method returns a grouped token.
732
737
 
733
738
  #### Parameters
734
739
  - `value` (`unknown`): The value to check.
735
- - `contentCheck` (`boolean`, optional): Whether to validate the contents of array tokens and the return values of convertible tokens. Defaults to `true`. When `false`, arrays are accepted without checking their elements, and convertible tokens with `rgxGroupWrap` set to `true` are accepted without checking their `toRgx()` return value.
740
+ - `contentCheck` (`boolean`, optional): Whether to validate the contents of array tokens and the return values of convertible tokens. Defaults to `true`. When `false`, arrays are accepted without checking their elements, and convertible tokens with `rgxGroupWrap` set to `true` are accepted without checking their `toRgx()` return value. This has no effect on the `rgxIsGroup` check, which always accepts the token as grouped regardless of `contentCheck`.
736
741
 
737
742
  #### Returns
738
743
  - `boolean`: `true` if the value is a grouped token, otherwise `false`.
@@ -746,7 +751,7 @@ Asserts that the given value is a grouped token. Uses the same logic as `isRGXGr
746
751
 
747
752
  #### Parameters
748
753
  - `value` (`unknown`): The value to assert.
749
- - `contentCheck` (`boolean`, optional): Whether to validate the contents of array tokens and the return values of convertible tokens. Defaults to `true`. When `false`, arrays are accepted without checking their elements, and convertible tokens with `rgxGroupWrap` set to `true` are accepted without checking their `toRgx()` return value.
754
+ - `contentCheck` (`boolean`, optional): Whether to validate the contents of array tokens and the return values of convertible tokens. Defaults to `true`. When `false`, arrays are accepted without checking their elements, and convertible tokens with `rgxGroupWrap` set to `true` are accepted without checking their `toRgx()` return value. This has no effect on the `rgxIsGroup` check, which always accepts the token as grouped regardless of `contentCheck`.
750
755
 
751
756
  #### Returns
752
757
  - `void`: This function does not return a value, but will throw an error if the assertion fails.
@@ -1208,6 +1213,19 @@ Tests whether the given regular expression matches at a specific position in the
1208
1213
  #### Returns
1209
1214
  - `boolean`: `true` if the regex matches at the specified position, otherwise `false`.
1210
1215
 
1216
+ ### cloneRGXToken
1217
+ ```typescript
1218
+ function cloneRGXTokeN<T extends RGXToken>(token: T, depth: CloneDepth="max"): T
1219
+ ```
1220
+ Creates a clone of the given RGX token to the given depth, provided that the token is not a no-op or native token.
1221
+
1222
+ #### Parameters
1223
+ - `token` (`T`): The RGX token to clone. Must not be a no-op or native token, or an error will be thrown.
1224
+ - `depth` (`CloneDepth`, optional): The depth to which to clone the token. Can be a number (with 0 resulting in no clone at all and 1 resulting in a shallow clone) or the string `"max"` for a full deep clone. Defaults to `"max"`.
1225
+
1226
+ #### Returns
1227
+ - `T`: The cloned token.
1228
+
1211
1229
  ## Peer Dependencies
1212
1230
  - `@ptolemy2002/immutability-utils` ^2.0.0
1213
1231
  - `@ptolemy2002/js-utils` ^3.2.2
@@ -1,16 +1,18 @@
1
- import { RGXToken, ValidRegexString } from "../types";
1
+ import { RGXConvertibleToken, RGXToken, ValidRegexString } from "../types";
2
2
  import { RGXTokenCollectionInput } from "../collection";
3
+ import { CloneDepth } from "@ptolemy2002/immutability-utils";
3
4
  import type { RGXClassUnionToken } from "./union";
4
5
  import type { RGXGroupToken, RGXGroupTokenArgs } from "./group";
5
6
  import type { RGXRepeatToken } from "./repeat";
6
7
  import type { RGXLookaheadToken } from "./lookahead";
7
8
  import type { RGXLookbehindToken } from "./lookbehind";
8
- export declare abstract class RGXClassToken {
9
+ export declare abstract class RGXClassToken implements RGXConvertibleToken {
9
10
  abstract toRgx(): RGXToken;
11
+ abstract clone(depth?: CloneDepth): ThisType<this>;
10
12
  static check: (value: unknown) => value is RGXClassToken;
11
13
  static assert: (value: unknown) => asserts value is RGXClassToken;
12
- get isGroup(): boolean;
13
- get isRepeatable(): boolean;
14
+ get rgxIsGroup(): boolean;
15
+ get rgxIsRepeatable(): boolean;
14
16
  get rgxGroupWrap(): boolean;
15
17
  or(...others: RGXTokenCollectionInput[]): RGXClassUnionToken;
16
18
  group(args?: RGXGroupTokenArgs): RGXGroupToken;
@@ -4,10 +4,10 @@ exports.RGXClassToken = void 0;
4
4
  const errors_1 = require("../errors");
5
5
  const resolve_1 = require("../resolve");
6
6
  class RGXClassToken {
7
- get isGroup() {
7
+ get rgxIsGroup() {
8
8
  return false;
9
9
  }
10
- get isRepeatable() {
10
+ get rgxIsRepeatable() {
11
11
  return true;
12
12
  }
13
13
  get rgxGroupWrap() {
@@ -1,5 +1,6 @@
1
1
  import { RGXTokenCollection, RGXTokenCollectionInput } from "../collection";
2
2
  import { RGXClassToken } from "./base";
3
+ import { CloneDepth } from "@ptolemy2002/immutability-utils";
3
4
  export type RGXGroupTokenArgs = {
4
5
  name?: string | null;
5
6
  capturing?: boolean;
@@ -14,9 +15,10 @@ export declare class RGXGroupToken extends RGXClassToken {
14
15
  set name(value: string | null);
15
16
  get capturing(): boolean;
16
17
  set capturing(value: boolean);
17
- get isGroup(): true;
18
+ get rgxIsGroup(): true;
18
19
  get rgxGroupWrap(): false;
19
20
  constructor({ name, capturing }?: RGXGroupTokenArgs, tokens?: RGXTokenCollectionInput);
20
21
  toRgx(): RegExp;
22
+ clone(depth?: CloneDepth): RGXGroupToken;
21
23
  }
22
24
  export declare const rgxGroup: (args_0?: RGXGroupTokenArgs | undefined, tokens?: RGXTokenCollectionInput) => RGXGroupToken;
@@ -5,6 +5,7 @@ const collection_1 = require("../collection");
5
5
  const base_1 = require("./base");
6
6
  const internal_1 = require("../internal");
7
7
  const typeGuards_1 = require("../typeGuards");
8
+ const immutability_utils_1 = require("@ptolemy2002/immutability-utils");
8
9
  class RGXGroupToken extends base_1.RGXClassToken {
9
10
  get name() {
10
11
  return this._name;
@@ -23,7 +24,7 @@ class RGXGroupToken extends base_1.RGXClassToken {
23
24
  this.name = null; // Non-capturing groups cannot have names
24
25
  this._capturing = value;
25
26
  }
26
- get isGroup() {
27
+ get rgxIsGroup() {
27
28
  return true;
28
29
  }
29
30
  get rgxGroupWrap() {
@@ -52,6 +53,11 @@ class RGXGroupToken extends base_1.RGXClassToken {
52
53
  result = `(${result})`;
53
54
  return new RegExp(result);
54
55
  }
56
+ clone(depth = "max") {
57
+ if (depth === 0)
58
+ return this;
59
+ return new RGXGroupToken({ name: this.name, capturing: this._capturing }, this.tokens.clone((0, immutability_utils_1.depthDecrement)(depth, 1)));
60
+ }
55
61
  }
56
62
  exports.RGXGroupToken = RGXGroupToken;
57
63
  RGXGroupToken.check = (0, internal_1.createClassGuardFunction)(RGXGroupToken);
@@ -36,11 +36,15 @@ function rgxClassInit() {
36
36
  base_1.RGXClassToken.prototype.asLookahead = function (positive = true) {
37
37
  if (lookahead_1.RGXLookaheadToken.check(this))
38
38
  return this;
39
+ if (lookbehind_1.RGXLookbehindToken.check(this))
40
+ return this.negate();
39
41
  return new lookahead_1.RGXLookaheadToken([this], positive);
40
42
  };
41
43
  base_1.RGXClassToken.prototype.asLookbehind = function (positive = true) {
42
44
  if (lookbehind_1.RGXLookbehindToken.check(this))
43
45
  return this;
46
+ if (lookahead_1.RGXLookaheadToken.check(this))
47
+ return this.negate();
44
48
  return new lookbehind_1.RGXLookbehindToken([this], positive);
45
49
  };
46
50
  }
@@ -1,11 +1,13 @@
1
1
  import { RGXToken } from "../types";
2
2
  import { RGXLookaroundToken } from "./lookaround";
3
3
  import { RGXLookbehindToken } from "./lookbehind";
4
+ import { CloneDepth } from "@ptolemy2002/immutability-utils";
4
5
  export declare class RGXLookaheadToken extends RGXLookaroundToken {
5
6
  static check: (value: unknown) => value is RGXLookaheadToken;
6
7
  static assert: (value: unknown) => asserts value is RGXLookaheadToken;
7
8
  negate(): RGXLookaheadToken;
8
9
  reverse(): RGXLookbehindToken;
9
10
  toRgx(): RGXToken;
11
+ clone(depth?: CloneDepth): RGXLookaheadToken;
10
12
  }
11
13
  export declare const rgxLookahead: (tokens?: import("..").RGXTokenCollectionInput, positive?: boolean | undefined) => RGXLookaheadToken;
@@ -4,6 +4,7 @@ exports.rgxLookahead = exports.RGXLookaheadToken = void 0;
4
4
  const internal_1 = require("../internal");
5
5
  const lookaround_1 = require("./lookaround");
6
6
  const lookbehind_1 = require("./lookbehind");
7
+ const immutability_utils_1 = require("@ptolemy2002/immutability-utils");
7
8
  class RGXLookaheadToken extends lookaround_1.RGXLookaroundToken {
8
9
  negate() {
9
10
  return new RGXLookaheadToken(this.tokens, !this.positive);
@@ -19,6 +20,11 @@ class RGXLookaheadToken extends lookaround_1.RGXLookaroundToken {
19
20
  result = `(?!${result})`;
20
21
  return new RegExp(result);
21
22
  }
23
+ clone(depth = "max") {
24
+ if (depth === 0)
25
+ return this;
26
+ return new RGXLookaheadToken(this.tokens.clone((0, immutability_utils_1.depthDecrement)(depth, 1)), this.positive);
27
+ }
22
28
  }
23
29
  exports.RGXLookaheadToken = RGXLookaheadToken;
24
30
  RGXLookaheadToken.check = (0, internal_1.createClassGuardFunction)(RGXLookaheadToken);
@@ -5,8 +5,8 @@ export declare abstract class RGXLookaroundToken extends RGXClassToken {
5
5
  _negative: boolean;
6
6
  static check: (value: unknown) => value is RGXLookaroundToken;
7
7
  static assert: (value: unknown) => asserts value is RGXLookaroundToken;
8
- get isGroup(): true;
9
- get isRepeatable(): false;
8
+ get rgxIsGroup(): true;
9
+ get rgxIsRepeatable(): false;
10
10
  get rgxGroupWrap(): false;
11
11
  set negative(value: boolean);
12
12
  get negative(): boolean;
@@ -5,10 +5,10 @@ const collection_1 = require("../collection");
5
5
  const base_1 = require("./base");
6
6
  const errors_1 = require("../errors");
7
7
  class RGXLookaroundToken extends base_1.RGXClassToken {
8
- get isGroup() {
8
+ get rgxIsGroup() {
9
9
  return true;
10
10
  }
11
- get isRepeatable() {
11
+ get rgxIsRepeatable() {
12
12
  return false;
13
13
  }
14
14
  get rgxGroupWrap() {
@@ -1,12 +1,13 @@
1
- import { RGXTokenCollectionInput } from "../collection";
2
1
  import { RGXToken } from "../types";
3
2
  import { RGXLookaheadToken } from "./lookahead";
4
3
  import { RGXLookaroundToken } from "./lookaround";
4
+ import { CloneDepth } from "@ptolemy2002/immutability-utils";
5
5
  export declare class RGXLookbehindToken extends RGXLookaroundToken {
6
6
  static check: (value: unknown) => value is RGXLookbehindToken;
7
7
  static assert: (value: unknown) => asserts value is RGXLookbehindToken;
8
8
  negate(): RGXLookbehindToken;
9
9
  reverse(): RGXLookaheadToken;
10
10
  toRgx(): RGXToken;
11
+ clone(depth?: CloneDepth): RGXLookbehindToken;
11
12
  }
12
- export declare const rgxLookbehind: (tokens?: RGXTokenCollectionInput, positive?: boolean | undefined) => RGXLookbehindToken;
13
+ export declare const rgxLookbehind: (tokens?: import("..").RGXTokenCollectionInput, positive?: boolean | undefined) => RGXLookbehindToken;
@@ -4,6 +4,7 @@ exports.rgxLookbehind = exports.RGXLookbehindToken = void 0;
4
4
  const internal_1 = require("../internal");
5
5
  const lookahead_1 = require("./lookahead");
6
6
  const lookaround_1 = require("./lookaround");
7
+ const immutability_utils_1 = require("@ptolemy2002/immutability-utils");
7
8
  class RGXLookbehindToken extends lookaround_1.RGXLookaroundToken {
8
9
  negate() {
9
10
  return new RGXLookbehindToken(this.tokens, !this.positive);
@@ -19,6 +20,11 @@ class RGXLookbehindToken extends lookaround_1.RGXLookaroundToken {
19
20
  result = `(?<!${result})`;
20
21
  return new RegExp(result);
21
22
  }
23
+ clone(depth = "max") {
24
+ if (depth === 0)
25
+ return this;
26
+ return new RGXLookbehindToken(this.tokens.clone((0, immutability_utils_1.depthDecrement)(depth, 1)), this.positive);
27
+ }
22
28
  }
23
29
  exports.RGXLookbehindToken = RGXLookbehindToken;
24
30
  RGXLookbehindToken.check = (0, internal_1.createClassGuardFunction)(RGXLookbehindToken);
@@ -1,5 +1,6 @@
1
1
  import { RGXGroupedToken, RGXToken } from "../types";
2
2
  import { RGXClassToken } from "./base";
3
+ import { CloneDepth } from "@ptolemy2002/immutability-utils";
3
4
  export declare class RGXRepeatToken extends RGXClassToken {
4
5
  _token: RGXGroupedToken;
5
6
  _min: number;
@@ -10,11 +11,12 @@ export declare class RGXRepeatToken extends RGXClassToken {
10
11
  set min(value: number);
11
12
  get max(): number | null;
12
13
  set max(value: number | null);
13
- get token(): RGXToken;
14
+ get token(): RGXGroupedToken;
14
15
  set token(value: RGXToken);
15
16
  get rgxGroupWrap(): false;
16
17
  constructor(token: RGXToken, min?: number, max?: number | null);
17
18
  get repeaterSuffix(): string;
18
19
  toRgx(): RGXToken;
20
+ clone(depth?: CloneDepth): RGXRepeatToken;
19
21
  }
20
22
  export declare const rgxRepeat: (token: RGXToken, min?: number | undefined, max?: number | null | undefined) => RGXRepeatToken;
@@ -7,6 +7,8 @@ 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 immutability_utils_1 = require("@ptolemy2002/immutability-utils");
11
+ const clone_1 = require("../clone");
10
12
  class RGXRepeatToken extends base_1.RGXClassToken {
11
13
  get min() {
12
14
  return this._min;
@@ -30,8 +32,13 @@ class RGXRepeatToken extends base_1.RGXClassToken {
30
32
  return this._token;
31
33
  }
32
34
  set token(value) {
33
- if ((0, typeGuards_1.isRGXToken)(value, "class") && !value.isRepeatable) {
34
- throw new errors_1.RGXNotSupportedError(`Repeating ${value.constructor.name} tokens`, "The token was manually marked as non-repeatable.");
35
+ if ((0, typeGuards_1.isRGXToken)(value, "convertible") && !value.rgxIsRepeatable) {
36
+ if ((0, typeGuards_1.isRGXToken)(value, "class")) {
37
+ throw new errors_1.RGXNotSupportedError(`Repeating ${value.constructor.name} tokens`, "The token was manually marked as non-repeatable.");
38
+ }
39
+ else {
40
+ throw new errors_1.RGXNotSupportedError("Repeating tokens with {rgxIsRepeatable: false}", "The token was manually marked as non-repeatable.");
41
+ }
35
42
  }
36
43
  // Make sure we are always working with a grouped token.
37
44
  if ((0, typeGuards_1.isRGXGroupedToken)(value))
@@ -76,6 +83,11 @@ class RGXRepeatToken extends base_1.RGXClassToken {
76
83
  const resolvedSource = (0, resolve_1.resolveRGXToken)(this.token);
77
84
  return new RegExp(`${resolvedSource}${this.repeaterSuffix}`);
78
85
  }
86
+ clone(depth = "max") {
87
+ if (depth === 0)
88
+ return this;
89
+ return new RGXRepeatToken((0, clone_1.cloneRGXToken)(this.token, (0, immutability_utils_1.depthDecrement)(depth, 1)), this.min, this.max);
90
+ }
79
91
  }
80
92
  exports.RGXRepeatToken = RGXRepeatToken;
81
93
  RGXRepeatToken.check = (0, internal_1.createClassGuardFunction)(RGXRepeatToken);
@@ -1,6 +1,7 @@
1
1
  import { RGXToken } from "../types";
2
2
  import { RGXTokenCollection, RGXTokenCollectionInput } from "../collection";
3
3
  import { RGXClassToken } from "./base";
4
+ import { CloneDepth } from "@ptolemy2002/immutability-utils";
4
5
  export type RGXUnionInsertionPosition = 'prefix' | 'suffix';
5
6
  export declare class RGXClassUnionToken extends RGXClassToken {
6
7
  tokens: RGXTokenCollection;
@@ -11,6 +12,7 @@ export declare class RGXClassUnionToken extends RGXClassToken {
11
12
  add(token: RGXToken, pos?: RGXUnionInsertionPosition): this;
12
13
  concat(pos?: RGXUnionInsertionPosition, ...others: RGXTokenCollectionInput[]): this;
13
14
  toRgx(): RegExp;
15
+ clone(depth?: CloneDepth): RGXClassUnionToken;
14
16
  }
15
17
  export declare function expandRgxUnionTokens(...tokens: RGXTokenCollectionInput[]): RGXTokenCollection;
16
18
  export declare function removeRgxUnionDuplicates(...tokens: RGXTokenCollectionInput[]): RGXTokenCollection;
@@ -6,6 +6,7 @@ exports.removeRgxUnionDuplicates = removeRgxUnionDuplicates;
6
6
  const internal_1 = require("../internal");
7
7
  const collection_1 = require("../collection");
8
8
  const base_1 = require("./base");
9
+ const immutability_utils_1 = require("@ptolemy2002/immutability-utils");
9
10
  class RGXClassUnionToken extends base_1.RGXClassToken {
10
11
  constructor(tokens = []) {
11
12
  super();
@@ -44,6 +45,11 @@ class RGXClassUnionToken extends base_1.RGXClassToken {
44
45
  toRgx() {
45
46
  return this.tokens.toRgx();
46
47
  }
48
+ clone(depth = "max") {
49
+ if (depth === 0)
50
+ return this;
51
+ return new RGXClassUnionToken(this.tokens.clone((0, immutability_utils_1.depthDecrement)(depth, 1)));
52
+ }
47
53
  }
48
54
  exports.RGXClassUnionToken = RGXClassUnionToken;
49
55
  RGXClassUnionToken.check = (0, internal_1.createClassGuardFunction)(RGXClassUnionToken);
@@ -1,13 +1,15 @@
1
1
  import { RGXToken } from "../types";
2
2
  import { RGXClassToken } from "./base";
3
+ import { CloneDepth } from "@ptolemy2002/immutability-utils";
3
4
  export declare class RGXClassWrapperToken extends RGXClassToken {
4
5
  token: RGXToken;
5
6
  static check: (value: unknown) => value is RGXClassWrapperToken;
6
7
  static assert: (value: unknown) => asserts value is RGXClassWrapperToken;
7
8
  constructor(token: RGXToken);
8
- get isGroup(): boolean;
9
- get isRepeatable(): boolean;
9
+ get rgxIsGroup(): boolean;
10
+ get rgxIsRepeatable(): boolean;
10
11
  unwrap(): RGXToken;
11
12
  toRgx(): RGXToken;
13
+ clone(depth?: CloneDepth): RGXClassWrapperToken;
12
14
  }
13
15
  export declare const rgxClassWrapper: (token: RGXToken) => RGXClassWrapperToken;
@@ -4,17 +4,19 @@ exports.rgxClassWrapper = exports.RGXClassWrapperToken = void 0;
4
4
  const base_1 = require("./base");
5
5
  const typeGuards_1 = require("../typeGuards");
6
6
  const internal_1 = require("../internal");
7
+ const immutability_utils_1 = require("@ptolemy2002/immutability-utils");
8
+ const clone_1 = require("../clone");
7
9
  class RGXClassWrapperToken extends base_1.RGXClassToken {
8
10
  constructor(token) {
9
11
  super();
10
12
  this.token = token;
11
13
  }
12
- get isGroup() {
14
+ get rgxIsGroup() {
13
15
  return (0, typeGuards_1.isRGXGroupedToken)(this.token);
14
16
  }
15
- get isRepeatable() {
17
+ get rgxIsRepeatable() {
16
18
  if ((0, typeGuards_1.isRGXToken)(this.token, 'class'))
17
- return this.token.isRepeatable;
19
+ return this.token.rgxIsRepeatable;
18
20
  // Assume any other token is repeatable, since we don't know its implementation.
19
21
  return true;
20
22
  }
@@ -24,6 +26,11 @@ class RGXClassWrapperToken extends base_1.RGXClassToken {
24
26
  toRgx() {
25
27
  return this.unwrap();
26
28
  }
29
+ clone(depth = "max") {
30
+ if (depth === 0)
31
+ return this;
32
+ return new RGXClassWrapperToken((0, clone_1.cloneRGXToken)(this.token, (0, immutability_utils_1.depthDecrement)(depth, 1)));
33
+ }
27
34
  }
28
35
  exports.RGXClassWrapperToken = RGXClassWrapperToken;
29
36
  RGXClassWrapperToken.check = (0, internal_1.createClassGuardFunction)(RGXClassWrapperToken);
@@ -0,0 +1,3 @@
1
+ import { CloneDepth } from "@ptolemy2002/immutability-utils";
2
+ import { RGXToken } from "./types";
3
+ export declare function cloneRGXToken<T extends RGXToken>(token: T, depth?: CloneDepth): T;
package/dist/clone.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cloneRGXToken = cloneRGXToken;
4
+ const immutability_utils_1 = require("@ptolemy2002/immutability-utils");
5
+ const typeGuards_1 = require("./typeGuards");
6
+ function cloneRGXToken(token, depth = "max") {
7
+ if (depth === 0)
8
+ return token;
9
+ if ((0, typeGuards_1.isRGXToken)(token, "no-op") || (0, typeGuards_1.isRGXToken)(token, "native"))
10
+ return token;
11
+ return (0, immutability_utils_1.extClone)(token, (0, immutability_utils_1.depthDecrement)(depth, 1));
12
+ }
package/dist/index.d.ts CHANGED
@@ -10,5 +10,6 @@ export * from "./concat";
10
10
  export * from "./utils";
11
11
  export * from "./ExtRegExp";
12
12
  export * from "./flag-transformer";
13
+ export * from "./clone";
13
14
  export declare function rgxa(tokens: t.RGXToken[], flags?: string): ExtRegExp;
14
15
  export default function rgx(flags?: string): (strings: TemplateStringsArray, ...tokens: t.RGXToken[]) => ExtRegExp;
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ __exportStar(require("./concat"), exports);
31
31
  __exportStar(require("./utils"), exports);
32
32
  __exportStar(require("./ExtRegExp"), exports);
33
33
  __exportStar(require("./flag-transformer"), exports);
34
+ __exportStar(require("./clone"), exports);
34
35
  // Call this for certain class methods to work correctly
35
36
  (0, class_1.rgxClassInit)();
36
37
  // Call this for our custom flags to work correctly
@@ -91,9 +91,13 @@ function assertRGXNativeToken(value) {
91
91
  }
92
92
  function isRGXConvertibleToken(value, returnCheck = true) {
93
93
  if (typeof value === 'object' && value !== null && 'toRgx' in value) {
94
- // The rgxGroupWrap property is optional, but if it exists it must be a boolean.
94
+ // The rgxGroupWrap, rgxIsRepeatable, and rgxIsGroup properties are optional, but if they exist they must be booleans.
95
95
  if ('rgxGroupWrap' in value && typeof value.rgxGroupWrap !== 'boolean')
96
96
  return false;
97
+ if ('rgxIsRepeatable' in value && typeof value.rgxIsRepeatable !== 'boolean')
98
+ return false;
99
+ if ('rgxIsGroup' in value && typeof value.rgxIsGroup !== 'boolean')
100
+ return false;
97
101
  if ((0, is_callable_1.default)(value.toRgx)) {
98
102
  if (!returnCheck)
99
103
  return true;
@@ -200,8 +204,8 @@ function isRGXGroupedToken(value, contentCheck = true) {
200
204
  // Classes are only groups if they have the isGroup property set to true.
201
205
  return (isRGXArrayToken(value, contentCheck) ||
202
206
  isRGXToken(value, "literal") ||
203
- (isRGXToken(value, "class") && value.isGroup) ||
204
- (isRGXConvertibleToken(value, false) && value.rgxGroupWrap === true && (!contentCheck || isRGXGroupedToken(value.toRgx()))));
207
+ (isRGXConvertibleToken(value, false) && (value.rgxIsGroup ||
208
+ (value.rgxGroupWrap === true && (!contentCheck || isRGXGroupedToken(value.toRgx()))))));
205
209
  }
206
210
  function assertRGXGroupedToken(value, contentCheck = true) {
207
211
  if (!isRGXGroupedToken(value, contentCheck)) {
package/dist/types.d.ts CHANGED
@@ -8,19 +8,21 @@ export type RGXNativeToken = string | number | boolean | RGXNoOpToken;
8
8
  export type RGXConvertibleToken = {
9
9
  toRgx: () => RGXToken;
10
10
  readonly rgxGroupWrap?: boolean;
11
+ readonly rgxIsGroup?: boolean;
12
+ readonly rgxIsRepeatable?: boolean;
11
13
  };
12
14
  export type RGXToken = RGXNativeToken | RGXLiteralToken | RGXConvertibleToken | RGXToken[];
13
15
  export type RGXClassTokenConstructor = new (...args: unknown[]) => RGXClassToken;
14
- export type RGXGroupedToken = RGXToken[] | RGXLiteralToken | (RGXClassToken & {
15
- isGroup: true;
16
- }) | RGXGroupedConvertibleToken;
17
- export type RGXGroupedConvertibleToken = {
16
+ export type RGXGroupedToken = RGXToken[] | RGXLiteralToken | RGXGroupedConvertibleToken;
17
+ export type RGXGroupedConvertibleToken = (RGXConvertibleToken & {
18
+ readonly rgxIsGroup: true;
19
+ }) | (Omit<RGXConvertibleToken, "toRGX"> & {
18
20
  toRgx: () => RGXGroupedToken;
19
21
  readonly rgxGroupWrap: true;
20
- };
22
+ });
21
23
  export type RGXTokenType = 'no-op' | 'literal' | 'native' | 'convertible' | 'class' | RGXTokenType[];
22
24
  export type RGXTokenTypeFlat = Exclude<RGXTokenType, RGXTokenType[]> | "array";
23
- export type RGXTokenTypeGuardInput = RGXTokenTypeFlat | null | RGXClassTokenConstructor | typeof ExtRegExp | typeof RGXTokenCollection | RGXTokenTypeGuardInput[];
25
+ export type RGXTokenTypeGuardInput = RGXTokenTypeFlat | null | RGXClassTokenConstructor | typeof RegExp | typeof ExtRegExp | typeof RGXTokenCollection | RGXTokenTypeGuardInput[];
24
26
  export type RGXTokenFromType<T extends RGXTokenTypeGuardInput> = T extends null ? RGXToken : T extends 'no-op' ? RGXNoOpToken : T extends 'literal' ? RGXLiteralToken : T extends 'native' ? RGXNativeToken : T extends 'convertible' ? RGXConvertibleToken : T extends 'class' ? RGXClassToken : T extends 'array' ? RGXToken[] : T extends new (...args: unknown[]) => infer R ? R : T extends RGXTokenTypeGuardInput[] ? {
25
27
  [K in keyof T]: T[K] extends RGXTokenTypeGuardInput ? RGXTokenFromType<T[K]> : never;
26
28
  } : never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptolemy2002/rgx",
3
- "version": "4.10.0",
3
+ "version": "5.0.0",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",