@thi.ng/parse 2.3.2 → 2.4.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-09-15T12:33:37Z
3
+ - **Last updated**: 2023-10-23T07:37:37Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [2.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/parse@2.4.0) (2023-09-19)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add ParseContext.peakDepth, update recursion limit ([0a2b7db](https://github.com/thi-ng/umbrella/commit/0a2b7db))
17
+
12
18
  ## [2.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/parse@2.3.0) (2023-09-06)
13
19
 
14
20
  #### 🚀 Features
package/README.md CHANGED
@@ -90,7 +90,7 @@ For Node.js REPL:
90
90
  const parse = await import("@thi.ng/parse");
91
91
  ```
92
92
 
93
- Package sizes (brotli'd, pre-treeshake): ESM: 5.09 KB
93
+ Package sizes (brotli'd, pre-treeshake): ESM: 5.11 KB
94
94
 
95
95
  ## Dependencies
96
96
 
package/api.d.ts CHANGED
@@ -53,9 +53,10 @@ export interface Language {
53
53
  }
54
54
  export interface ContextOpts {
55
55
  /**
56
- * Max recursion depth failsafe.
56
+ * Max recursion depth failsafe. Parsing will terminate once this limit is
57
+ * reached.
57
58
  *
58
- * @defaultVal 32
59
+ * @defaultVal 64
59
60
  */
60
61
  maxDepth: number;
61
62
  /**
package/context.d.ts CHANGED
@@ -5,6 +5,7 @@ export declare class ParseContext<T> {
5
5
  protected _scopes: ParseScope<T>[];
6
6
  protected _curr: ParseScope<T>;
7
7
  protected _maxDepth: number;
8
+ protected _peakDepth: number;
8
9
  protected _debug: boolean;
9
10
  protected _retain: boolean;
10
11
  constructor(reader: IReader<T>, opts?: Partial<ContextOpts>);
@@ -29,6 +30,11 @@ export declare class ParseContext<T> {
29
30
  * Returns root node's children or `undefined`.
30
31
  */
31
32
  get children(): import("@thi.ng/api").Nullable<ParseScope<T>[]>;
33
+ /**
34
+ * Returns max. recursion depth which was actually reached. Will always be
35
+ * less or equal configured {@link ContextOpts.maxDepth}.
36
+ */
37
+ get peakDepth(): number;
32
38
  }
33
39
  /**
34
40
  * Creates new {@link ParseContext} for given input string, array or
package/context.js CHANGED
@@ -7,7 +7,7 @@ import { indent } from "./utils.js";
7
7
  export class ParseContext {
8
8
  constructor(reader, opts) {
9
9
  this.reader = reader;
10
- this.opts = { maxDepth: 32, debug: false, retain: false, ...opts };
10
+ this.opts = { maxDepth: 64, debug: false, retain: false, ...opts };
11
11
  this._maxDepth = this.opts.maxDepth;
12
12
  this._debug = this.opts.debug;
13
13
  this._retain = this.opts.retain;
@@ -21,6 +21,7 @@ export class ParseContext {
21
21
  result: null,
22
22
  };
23
23
  this._scopes = [this._curr];
24
+ this._peakDepth = 1;
24
25
  this.reader.isDone(this._curr.state);
25
26
  return this;
26
27
  }
@@ -36,6 +37,7 @@ export class ParseContext {
36
37
  result: null,
37
38
  };
38
39
  scopes.push(scope);
40
+ this._peakDepth = Math.max(this._peakDepth, scopes.length);
39
41
  this._debug &&
40
42
  console.log(`${indent(scopes.length)}start: ${id} (${scope.state.p})`);
41
43
  return (this._curr = scope);
@@ -120,6 +122,13 @@ export class ParseContext {
120
122
  const children = this.root.children;
121
123
  return children ? children[0].children : undefined;
122
124
  }
125
+ /**
126
+ * Returns max. recursion depth which was actually reached. Will always be
127
+ * less or equal configured {@link ContextOpts.maxDepth}.
128
+ */
129
+ get peakDepth() {
130
+ return this._peakDepth;
131
+ }
123
132
  }
124
133
  export function defContext(input, opts) {
125
134
  return new ParseContext(isString(input)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/parse",
3
- "version": "2.3.2",
3
+ "version": "2.4.1",
4
4
  "description": "Purely functional parser combinators & AST generation for generic inputs",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -34,18 +34,18 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.9.5",
38
- "@thi.ng/checks": "^3.4.5",
39
- "@thi.ng/defmulti": "^3.0.0",
40
- "@thi.ng/errors": "^2.3.5",
41
- "@thi.ng/strings": "^3.6.0"
37
+ "@thi.ng/api": "^8.9.6",
38
+ "@thi.ng/checks": "^3.4.6",
39
+ "@thi.ng/defmulti": "^3.0.1",
40
+ "@thi.ng/errors": "^2.3.6",
41
+ "@thi.ng/strings": "^3.6.1"
42
42
  },
43
43
  "devDependencies": {
44
- "@microsoft/api-extractor": "^7.36.4",
45
- "@thi.ng/testament": "^0.3.23",
46
- "rimraf": "^5.0.1",
44
+ "@microsoft/api-extractor": "^7.38.0",
45
+ "@thi.ng/testament": "^0.3.24",
46
+ "rimraf": "^5.0.5",
47
47
  "tools": "^0.0.1",
48
- "typedoc": "^0.25.0",
48
+ "typedoc": "^0.25.2",
49
49
  "typescript": "^5.2.2"
50
50
  },
51
51
  "keywords": [
@@ -241,5 +241,5 @@
241
241
  ],
242
242
  "year": 2020
243
243
  },
244
- "gitHead": "c22e8996cee284ebe8ea88582beb1ab5fc6ee503\n"
244
+ "gitHead": "8d46d9326a9f9b81d65e7e274446f5964f9942ac\n"
245
245
  }