@ptolemy2002/rgx 5.2.0 → 5.3.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
@@ -912,7 +912,7 @@ For convertible tokens, if the token has an `rgxGroupWrap` property, that value
912
912
  function rgxConcat(tokens: RGXToken[], groupWrap?: boolean, currentFlags?: string): ValidRegexString
913
913
  ```
914
914
 
915
- A helper function that resolves an array of RGX tokens and concatenates their resolved string representations together. This is useful for cases where you want to concatenate multiple tokens without creating a union between them. Before returning, any convertible token in the array that defines `rgxAcceptInsertion` is checked; if it returns `false` or a string, an `RGXInsertionRejectedError` is thrown.
915
+ A helper function that resolves an array of RGX tokens and concatenates their resolved string representations together. This is useful for cases where you want to concatenate multiple tokens without creating a union between them. Before returning, any convertible token in the array that defines `rgxAcceptInsertion` is checked; if it returns `false` or a string, an `RGXInsertionRejectedError` is thrown with details about the reason and exactly where the rejection occurred.
916
916
 
917
917
  #### Parameters
918
918
  - `tokens` (`RGXToken[]`): The array of RGX tokens to resolve and concatenate.
@@ -927,7 +927,7 @@ A helper function that resolves an array of RGX tokens and concatenates their re
927
927
  function rgx(flags?: string): (strings: TemplateStringsArray, ...tokens: RGXToken[]) => ExtRegExp
928
928
  ```
929
929
 
930
- Creates and returns a template tag function that constructs an `ExtRegExp` object from the provided template literal with the provided flags. The template literal can contain RGX tokens, which will be resolved and concatenated with the literal parts to form the final regex pattern. Before constructing the pattern, any convertible token that defines `rgxAcceptInsertion` is checked; if it returns `false` or a string, an `RGXInsertionRejectedError` is thrown.
930
+ Creates and returns a template tag function that constructs an `ExtRegExp` object from the provided template literal with the provided flags. The template literal can contain RGX tokens, which will be resolved and concatenated with the literal parts to form the final regex pattern. Before constructing the pattern, any convertible token that defines `rgxAcceptInsertion` is checked; if it returns `false` or a string, an `RGXInsertionRejectedError` is thrown with details about the reason and exactly where the rejection occurred.
931
931
 
932
932
  The provided `flags` are passed as `currentFlags` to the resolver, enabling inline modifier groups for any `RegExp` literal tokens whose localizable flags (`i`, `m`, `s`) differ from the parent flags. For example, embedding `/foo/i` in a no-flag context produces `(?i:foo)`, while embedding `/bar/` in an `i`-flag context produces `(?-i:bar)`.
933
933
 
@@ -962,7 +962,7 @@ const pattern4 = rgx()`${beginning}${caseInsensitiveWord} world${end}`; // /^(?i
962
962
  ```typescript
963
963
  function rgxa(tokens: RGXToken[], flags?: string): ExtRegExp
964
964
  ```
965
- As an alternative to using the `rgx` template tag, you can directly call `rgxa` with an array of RGX tokens and optional flags to get an `ExtRegExp` object. This is useful in cases where you don't want to use a template literal. Like `rgx`, the provided `flags` are passed as `currentFlags` to the resolver, enabling inline modifier groups for `RegExp` literal tokens whose localizable flags differ. Before constructing the pattern, any convertible token in the array that defines `rgxAcceptInsertion` is checked; if it returns `false` or a string, an `RGXInsertionRejectedError` is thrown.
965
+ As an alternative to using the `rgx` template tag, you can directly call `rgxa` with an array of RGX tokens and optional flags to get an `ExtRegExp` object. This is useful in cases where you don't want to use a template literal. Like `rgx`, the provided `flags` are passed as `currentFlags` to the resolver, enabling inline modifier groups for `RegExp` literal tokens whose localizable flags differ. Before constructing the pattern, any convertible token in the array that defines `rgxAcceptInsertion` is checked; if it returns `false` or a string, an `RGXInsertionRejectedError` is thrown with details about the reason and exactly where the rejection occurred.
966
966
 
967
967
  #### Parameters
968
968
  - `tokens` (`RGXToken[]`): The RGX tokens to be resolved and concatenated to form the regex pattern.
@@ -1,17 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assureAcceptance = assureAcceptance;
4
+ const class_1 = require("../class");
4
5
  const errors_1 = require("../errors");
5
6
  const typeGuards_1 = require("../typeGuards");
6
7
  function assureAcceptance(tokens, flags) {
7
- for (const token of tokens) {
8
+ for (let i = 0; i < tokens.length; i++) {
9
+ const token = tokens[i];
8
10
  if ((0, typeGuards_1.isRGXConvertibleToken)(token) && token.rgxAcceptInsertion) {
9
11
  const messageOrAccepted = token.rgxAcceptInsertion(tokens, flags);
10
12
  if (messageOrAccepted === true)
11
13
  continue;
14
+ const extraMessage = `index ${i}, token type ${class_1.RGXClassToken.check(token) ? token.constructor.name : "unknown"}`;
12
15
  if (messageOrAccepted === false)
13
- throw new errors_1.RGXInsertionRejectedError();
14
- throw new errors_1.RGXInsertionRejectedError(messageOrAccepted);
16
+ throw new errors_1.RGXInsertionRejectedError(null, extraMessage);
17
+ throw new errors_1.RGXInsertionRejectedError(messageOrAccepted, extraMessage);
15
18
  }
16
19
  }
17
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptolemy2002/rgx",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",