regex-partial-match 1.1.1 → 1.1.2

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.
@@ -31,5 +31,6 @@ declare class PartialMatchRegExp extends RegExp {
31
31
  readonly features: ReadonlySet<RegexFeature>;
32
32
  constructor(pattern: RegExp | string, flags?: string);
33
33
  exec(input: string): RegExpExecArray | null;
34
+ private _execDynamic;
34
35
  }
35
36
  export default PartialMatchRegExp;
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _PartialMatchRegExp_instances, _PartialMatchRegExp_compiledPartial, _PartialMatchRegExp_execDynamic;
12
+ var _PartialMatchRegExp_compiledPartial;
13
13
  import { compilePartial } from "./compilePartial.js";
14
14
  /**
15
15
  * A `RegExp` subclass that supports partial (prefix) matching.
@@ -40,7 +40,6 @@ import { compilePartial } from "./compilePartial.js";
40
40
  class PartialMatchRegExp extends RegExp {
41
41
  constructor(pattern, flags) {
42
42
  super(pattern, flags);
43
- _PartialMatchRegExp_instances.add(this);
44
43
  _PartialMatchRegExp_compiledPartial.set(this, void 0);
45
44
  __classPrivateFieldSet(this, _PartialMatchRegExp_compiledPartial, compilePartial(this), "f");
46
45
  this.features = __classPrivateFieldGet(this, _PartialMatchRegExp_compiledPartial, "f").features;
@@ -48,40 +47,41 @@ class PartialMatchRegExp extends RegExp {
48
47
  exec(input) {
49
48
  const compiled = __classPrivateFieldGet(this, _PartialMatchRegExp_compiledPartial, "f");
50
49
  if (compiled.kind === "dynamic")
51
- return __classPrivateFieldGet(this, _PartialMatchRegExp_instances, "m", _PartialMatchRegExp_execDynamic).call(this, compiled.dynamic, input);
50
+ return this._execDynamic(compiled.dynamic, input);
52
51
  const { regex } = compiled;
53
52
  const match = execFrom(regex, input, this.lastIndex);
54
53
  this.lastIndex = regex.lastIndex;
55
54
  return match;
56
55
  }
57
- }
58
- _PartialMatchRegExp_compiledPartial = new WeakMap(), _PartialMatchRegExp_instances = new WeakSet(), _PartialMatchRegExp_execDynamic = function _PartialMatchRegExp_execDynamic(dynamic, input) {
59
- var _a, _b;
60
- const { originalCaptureScan, preScan, expand } = dynamic;
61
- const honoursLastIndex = this.global || this.sticky;
62
- const start = honoursLastIndex ? this.lastIndex : 0;
63
- const originalMatch = super.exec(input);
64
- if (isAtOrBefore(originalMatch, start))
65
- return originalMatch;
66
- let preScanMatch = null;
67
- if (originalMatch) {
68
- preScanMatch = execFrom(preScan, input, start);
69
- const noEarlierPartialPossible = preScanMatch === null || preScanMatch.index >= originalMatch.index;
70
- if (noEarlierPartialPossible)
56
+ _execDynamic(dynamic, input) {
57
+ var _a, _b;
58
+ const { originalCaptureScan, preScan, expand } = dynamic;
59
+ const honoursLastIndex = this.global || this.sticky;
60
+ const start = honoursLastIndex ? this.lastIndex : 0;
61
+ const originalMatch = super.exec(input);
62
+ if (isAtOrBefore(originalMatch, start))
63
+ return originalMatch;
64
+ let preScanMatch = null;
65
+ if (originalMatch) {
66
+ preScanMatch = execFrom(preScan, input, start);
67
+ const noEarlierPartialPossible = preScanMatch === null || preScanMatch.index >= originalMatch.index;
68
+ if (noEarlierPartialPossible)
69
+ return originalMatch;
70
+ }
71
+ const capture = (_b = (_a = execFrom(originalCaptureScan, input, start)) !== null && _a !== void 0 ? _a : preScanMatch) !== null && _b !== void 0 ? _b : execFrom(preScan, input, start);
72
+ if (capture === null)
73
+ return originalMatch;
74
+ const expanded = new RegExp(expand(capture), this.flags);
75
+ const match = execFrom(expanded, input, start);
76
+ if (match === null || isAtOrBefore(originalMatch, match.index))
71
77
  return originalMatch;
78
+ preferLongerCaptures(match, capture);
79
+ if (honoursLastIndex)
80
+ this.lastIndex = expanded.lastIndex;
81
+ return match;
72
82
  }
73
- const capture = (_b = (_a = execFrom(originalCaptureScan, input, start)) !== null && _a !== void 0 ? _a : preScanMatch) !== null && _b !== void 0 ? _b : execFrom(preScan, input, start);
74
- if (capture === null)
75
- return originalMatch;
76
- const expanded = new RegExp(expand(capture), this.flags);
77
- const match = execFrom(expanded, input, start);
78
- if (match === null || isAtOrBefore(originalMatch, match.index))
79
- return originalMatch;
80
- preferLongerCaptures(match, capture);
81
- if (honoursLastIndex)
82
- this.lastIndex = expanded.lastIndex;
83
- return match;
84
- };
83
+ }
84
+ _PartialMatchRegExp_compiledPartial = new WeakMap();
85
85
  function execFrom(regex, input, start) {
86
86
  regex.lastIndex = start;
87
87
  return regex.exec(input);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "regex-partial-match",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "A regular expression transform for partial matching",
5
5
  "devEngines": {
6
6
  "runtime": {
@@ -62,6 +62,7 @@
62
62
  "lint:fix": "eslint . --fix",
63
63
  "prepare": "simple-git-hooks",
64
64
  "prepublishOnly": "tsc -p tsconfig.build.json",
65
+ "ci:smoke-test-built-package": "node .github/scripts/smoke-test-built-package.ts",
65
66
  "test": "vitest run --config ./test/vitest.config.ts",
66
67
  "test:watch": "vitest --config ./test/vitest.config.ts"
67
68
  },