@thi.ng/parse 2.4.62 → 2.4.64
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 +7 -1
- package/README.md +1 -1
- package/context.js +2 -4
- package/package.json +7 -7
- package/prims/anchor.js +4 -8
- package/prims/lit.js +2 -2
- package/prims/none-of.js +1 -1
- package/prims/one-of.js +1 -1
- package/prims/satisfy.js +1 -2
- package/prims/string.js +2 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**:
|
|
3
|
+
- **Last updated**: 2025-01-14T12:23:33Z
|
|
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.64](https://github.com/thi-ng/umbrella/tree/@thi.ng/parse@2.4.64) (2025-01-14)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- various minor updates ([42ce3f6](https://github.com/thi-ng/umbrella/commit/42ce3f6))
|
|
17
|
+
|
|
12
18
|
### [2.4.52](https://github.com/thi-ng/umbrella/tree/@thi.ng/parse@2.4.52) (2024-08-29)
|
|
13
19
|
|
|
14
20
|
#### ⏱ Performance improvements
|
package/README.md
CHANGED
package/context.js
CHANGED
|
@@ -88,8 +88,7 @@ class ParseContext {
|
|
|
88
88
|
);
|
|
89
89
|
child.state = this._retain ? parent.state.copy() : null;
|
|
90
90
|
parent.state = cstate;
|
|
91
|
-
|
|
92
|
-
children ? children.push(child) : parent.children = [child];
|
|
91
|
+
parent.children?.push(child) ?? (parent.children = [child]);
|
|
93
92
|
this._curr = parent;
|
|
94
93
|
return true;
|
|
95
94
|
}
|
|
@@ -104,8 +103,7 @@ class ParseContext {
|
|
|
104
103
|
this._debug && console.log(
|
|
105
104
|
`${__indent(this._scopes.length + 1)}addChild: ${id} (${curr.state.p})`
|
|
106
105
|
);
|
|
107
|
-
|
|
108
|
-
children ? children.push(child) : curr.children = [child];
|
|
106
|
+
curr.children?.push(child) ?? (curr.children = [child]);
|
|
109
107
|
if (newState !== false) {
|
|
110
108
|
newState === true ? this.reader.next(curr.state) : this._curr.state = newState;
|
|
111
109
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/parse",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.64",
|
|
4
4
|
"description": "Purely functional parser combinators & AST generation for generic inputs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@thi.ng/api": "^8.11.
|
|
44
|
-
"@thi.ng/checks": "^3.6.
|
|
45
|
-
"@thi.ng/defmulti": "^3.0.
|
|
46
|
-
"@thi.ng/errors": "^2.5.
|
|
47
|
-
"@thi.ng/strings": "^3.
|
|
43
|
+
"@thi.ng/api": "^8.11.16",
|
|
44
|
+
"@thi.ng/checks": "^3.6.19",
|
|
45
|
+
"@thi.ng/defmulti": "^3.0.55",
|
|
46
|
+
"@thi.ng/errors": "^2.5.22",
|
|
47
|
+
"@thi.ng/strings": "^3.9.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@microsoft/api-extractor": "^7.48.1",
|
|
@@ -246,5 +246,5 @@
|
|
|
246
246
|
],
|
|
247
247
|
"year": 2020
|
|
248
248
|
},
|
|
249
|
-
"gitHead": "
|
|
249
|
+
"gitHead": "6542b842120bef47cc18d45a1b1db68307a7f04b\n"
|
|
250
250
|
}
|
package/prims/anchor.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { ALPHA_NUM } from "@thi.ng/strings/groups";
|
|
2
|
-
const anchor = (fn) => (
|
|
3
|
-
const state = ctx.state;
|
|
4
|
-
return fn(state.last, state.done ? null : ctx.reader.read(state));
|
|
5
|
-
};
|
|
2
|
+
const anchor = (fn) => ({ reader, state }) => fn(state.last, state.done ? null : reader.read(state));
|
|
6
3
|
const inputStart = (ctx) => ctx.state.last == null;
|
|
7
|
-
const inputEnd = (
|
|
4
|
+
const inputEnd = ({ reader, state }) => state.done || reader.read(state) === void 0;
|
|
8
5
|
const lineStart = (ctx) => {
|
|
9
6
|
const l = ctx.state.last;
|
|
10
7
|
return l == null || l === "\n" || l === "\r";
|
|
11
8
|
};
|
|
12
|
-
const lineEnd = (
|
|
13
|
-
const state = ctx.state;
|
|
9
|
+
const lineEnd = ({ reader, state }) => {
|
|
14
10
|
let c;
|
|
15
|
-
return state.done || (c =
|
|
11
|
+
return state.done || (c = reader.read(state)) === "\n" || c === "\r";
|
|
16
12
|
};
|
|
17
13
|
const wordBoundaryP = (prev, next) => {
|
|
18
14
|
return prev ? next ? ALPHA_NUM[prev] && !ALPHA_NUM[next] : ALPHA_NUM[prev] : next ? ALPHA_NUM[next] : false;
|
package/prims/lit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { satisfyD, satisfy } from "./satisfy.js";
|
|
2
2
|
const litP = (c) => (x) => x === c;
|
|
3
|
-
const lit = (c, id = "lit") => satisfy(
|
|
4
|
-
const litD = (c) => satisfyD(
|
|
3
|
+
const lit = (c, id = "lit") => satisfy((x) => x === c, id);
|
|
4
|
+
const litD = (c) => satisfyD((x) => x === c);
|
|
5
5
|
export {
|
|
6
6
|
lit,
|
|
7
7
|
litD,
|
package/prims/none-of.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isPlainObject } from "@thi.ng/checks/is-plain-object";
|
|
2
2
|
import { isSet } from "@thi.ng/checks/is-set";
|
|
3
3
|
import { satisfy, satisfyD } from "./satisfy.js";
|
|
4
|
-
const noneOfP = (opts) => isSet(opts) ? (x) => !opts.has(x) : isPlainObject(opts) ? (x) => !opts[x] : (x) => opts.
|
|
4
|
+
const noneOfP = (opts) => isSet(opts) ? (x) => !opts.has(x) : isPlainObject(opts) ? (x) => !opts[x] : (x) => !opts.includes(x);
|
|
5
5
|
function noneOf(opts, id = "noneOf") {
|
|
6
6
|
return satisfy(noneOfP(opts), id);
|
|
7
7
|
}
|
package/prims/one-of.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isPlainObject } from "@thi.ng/checks/is-plain-object";
|
|
2
2
|
import { isSet } from "@thi.ng/checks/is-set";
|
|
3
3
|
import { satisfy, satisfyD } from "./satisfy.js";
|
|
4
|
-
const oneOfP = (opts) => isSet(opts) ? (x) => opts.has(x) : isPlainObject(opts) ? (x) => opts[x] : (x) => opts.
|
|
4
|
+
const oneOfP = (opts) => isSet(opts) ? (x) => opts.has(x) : isPlainObject(opts) ? (x) => opts[x] : (x) => opts.includes(x);
|
|
5
5
|
function oneOf(opts, id = "oneOf") {
|
|
6
6
|
return satisfy(oneOfP(opts), id);
|
|
7
7
|
}
|
package/prims/satisfy.js
CHANGED
|
@@ -5,8 +5,7 @@ const satisfy = (pred, id = "satisfy") => (ctx) => {
|
|
|
5
5
|
};
|
|
6
6
|
const satisfyD = (pred) => (ctx) => {
|
|
7
7
|
if (ctx.done) return false;
|
|
8
|
-
const state = ctx
|
|
9
|
-
const reader = ctx.reader;
|
|
8
|
+
const { reader, state } = ctx;
|
|
10
9
|
return pred(reader.read(state)) ? (reader.next(state), true) : false;
|
|
11
10
|
};
|
|
12
11
|
export {
|
package/prims/string.js
CHANGED
|
@@ -5,8 +5,7 @@ const string = (str, id = "string") => (ctx) => {
|
|
|
5
5
|
const reader = ctx.reader;
|
|
6
6
|
for (let i = 0, n = str.length; i < n; i++) {
|
|
7
7
|
if (state.done) return false;
|
|
8
|
-
|
|
9
|
-
if (r !== str[i]) {
|
|
8
|
+
if (reader.read(state) !== str[i]) {
|
|
10
9
|
return ctx.discard();
|
|
11
10
|
}
|
|
12
11
|
reader.next(state);
|
|
@@ -20,8 +19,7 @@ const stringD = (str) => (ctx) => {
|
|
|
20
19
|
const reader = ctx.reader;
|
|
21
20
|
for (let i = 0, n = str.length; i < n; i++) {
|
|
22
21
|
if (state.done) return false;
|
|
23
|
-
|
|
24
|
-
if (r !== str[i]) {
|
|
22
|
+
if (reader.read(state) !== str[i]) {
|
|
25
23
|
return false;
|
|
26
24
|
}
|
|
27
25
|
reader.next(state);
|