@blackglory/match 0.3.6 → 0.4.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 +21 -32
- package/lib/index.d.ts +17 -17
- package/lib/index.js +17 -37
- package/lib/index.js.map +1 -1
- package/lib/match-element.d.ts +1 -1
- package/lib/match-element.js +7 -11
- package/lib/match-element.js.map +1 -1
- package/lib/match.d.ts +1 -1
- package/lib/match.js +7 -11
- package/lib/match.js.map +1 -1
- package/lib/matchers/any-of.d.ts +1 -1
- package/lib/matchers/any-of.js +1 -5
- package/lib/matchers/any-of.js.map +1 -1
- package/lib/matchers/child-nodes.d.ts +1 -1
- package/lib/matchers/child-nodes.js +8 -11
- package/lib/matchers/child-nodes.js.map +1 -1
- package/lib/matchers/children.d.ts +1 -1
- package/lib/matchers/children.js +8 -11
- package/lib/matchers/children.js.map +1 -1
- package/lib/matchers/css.d.ts +1 -1
- package/lib/matchers/css.js +5 -9
- package/lib/matchers/css.js.map +1 -1
- package/lib/matchers/element.d.ts +1 -1
- package/lib/matchers/element.js +10 -14
- package/lib/matchers/element.js.map +1 -1
- package/lib/matchers/multiple.d.ts +1 -1
- package/lib/matchers/multiple.js +14 -17
- package/lib/matchers/multiple.js.map +1 -1
- package/lib/matchers/node.d.ts +1 -1
- package/lib/matchers/node.js +8 -12
- package/lib/matchers/node.js.map +1 -1
- package/lib/matchers/optional.d.ts +1 -1
- package/lib/matchers/optional.js +3 -7
- package/lib/matchers/optional.js.map +1 -1
- package/lib/matchers/repeat.d.ts +1 -1
- package/lib/matchers/repeat.js +6 -10
- package/lib/matchers/repeat.js.map +1 -1
- package/lib/matchers/tap.d.ts +1 -1
- package/lib/matchers/tap.js +1 -5
- package/lib/matchers/tap.js.map +1 -1
- package/lib/matchers/text-content-equals.d.ts +1 -1
- package/lib/matchers/text-content-equals.js +3 -7
- package/lib/matchers/text-content-equals.js.map +1 -1
- package/lib/matchers/text-content-includes.d.ts +1 -1
- package/lib/matchers/text-content-includes.js +3 -7
- package/lib/matchers/text-content-includes.js.map +1 -1
- package/lib/matchers/text-content-matches.d.ts +1 -1
- package/lib/matchers/text-content-matches.js +3 -7
- package/lib/matchers/text-content-matches.js.map +1 -1
- package/lib/matchers/text-node.d.ts +1 -1
- package/lib/matchers/text-node.js +10 -14
- package/lib/matchers/text-node.js.map +1 -1
- package/lib/matchers/xpath.d.ts +1 -1
- package/lib/matchers/xpath.js +7 -11
- package/lib/matchers/xpath.js.map +1 -1
- package/lib/types.d.ts +4 -4
- package/lib/types.js +1 -2
- package/lib/utils/concat.js +1 -5
- package/lib/utils/concat.js.map +1 -1
- package/lib/utils/match-multiple.d.ts +4 -1
- package/lib/utils/match-multiple.js +6 -7
- package/lib/utils/match-multiple.js.map +1 -1
- package/lib/utils/match-one-by-one.d.ts +1 -1
- package/lib/utils/match-one-by-one.js +9 -9
- package/lib/utils/match-one-by-one.js.map +1 -1
- package/lib/utils/merge-in-place.d.ts +1 -5
- package/lib/utils/merge-in-place.js +5 -9
- package/lib/utils/merge-in-place.js.map +1 -1
- package/lib/utils/next-element-sibling.js +2 -6
- package/lib/utils/next-element-sibling.js.map +1 -1
- package/lib/utils/next-sibling.js +2 -6
- package/lib/utils/next-sibling.js.map +1 -1
- package/package.json +30 -29
- package/src/index.ts +17 -17
- package/src/match-element.ts +3 -3
- package/src/match.ts +3 -3
- package/src/matchers/any-of.ts +1 -1
- package/src/matchers/child-nodes.ts +4 -4
- package/src/matchers/children.ts +4 -4
- package/src/matchers/css.ts +3 -3
- package/src/matchers/element.ts +4 -4
- package/src/matchers/multiple.ts +3 -3
- package/src/matchers/node.ts +4 -4
- package/src/matchers/optional.ts +2 -2
- package/src/matchers/repeat.ts +3 -3
- package/src/matchers/tap.ts +1 -1
- package/src/matchers/text-content-equals.ts +2 -2
- package/src/matchers/text-content-includes.ts +2 -2
- package/src/matchers/text-content-matches.ts +2 -2
- package/src/matchers/text-node.ts +4 -4
- package/src/matchers/xpath.ts +4 -4
- package/src/utils/match-multiple.ts +1 -1
- package/src/utils/match-one-by-one.ts +2 -2
- package/src/utils/merge-in-place.ts +3 -3
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.mergeInPlace = void 0;
|
|
4
|
-
const types_1 = require("@blackglory/types");
|
|
5
|
-
function mergeInPlace(target, source) {
|
|
1
|
+
import { isArray } from '@blackglory/prelude';
|
|
2
|
+
export function mergeInPlace(target, source) {
|
|
6
3
|
for (const [key, value] of Object.entries(source)) {
|
|
7
4
|
if (target[key]) {
|
|
8
|
-
if (
|
|
9
|
-
if (
|
|
5
|
+
if (isArray(target[key])) {
|
|
6
|
+
if (isArray(value)) {
|
|
10
7
|
target[key] = [...target[key], ...value];
|
|
11
8
|
}
|
|
12
9
|
else {
|
|
@@ -14,7 +11,7 @@ function mergeInPlace(target, source) {
|
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
13
|
else {
|
|
17
|
-
if (
|
|
14
|
+
if (isArray(value)) {
|
|
18
15
|
target[key] = [target[key], ...value];
|
|
19
16
|
}
|
|
20
17
|
else {
|
|
@@ -27,5 +24,4 @@ function mergeInPlace(target, source) {
|
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
exports.mergeInPlace = mergeInPlace;
|
|
31
27
|
//# sourceMappingURL=merge-in-place.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-in-place.js","sourceRoot":"","sources":["../../src/utils/merge-in-place.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"merge-in-place.js","sourceRoot":"","sources":["../../src/utils/merge-in-place.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE7C,MAAM,UAAU,YAAY,CAC1B,MAA+B,EAC/B,MAA+B;IAE/B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YAChB,IAAI,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBACzB,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAQ,EAAE,GAAG,KAAK,CAAC,CAAA;gBACjD,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAQ,EAAE,KAAK,CAAC,CAAA;gBAC9C,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAM,EAAE,GAAG,KAAK,CAAC,CAAA;gBAC5C,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAM,EAAE,KAAK,CAAC,CAAA;gBACzC,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACrB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.nextElementSibling = void 0;
|
|
4
|
-
const ExtraDOM = require("extra-dom");
|
|
5
|
-
function nextElementSibling(node, distance = 1) {
|
|
1
|
+
import * as ExtraDOM from 'extra-dom';
|
|
2
|
+
export function nextElementSibling(node, distance = 1) {
|
|
6
3
|
if (distance === 0)
|
|
7
4
|
return node;
|
|
8
5
|
return ExtraDOM.nextElementSibling(node, distance);
|
|
9
6
|
}
|
|
10
|
-
exports.nextElementSibling = nextElementSibling;
|
|
11
7
|
//# sourceMappingURL=next-element-sibling.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-element-sibling.js","sourceRoot":"","sources":["../../src/utils/next-element-sibling.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"next-element-sibling.js","sourceRoot":"","sources":["../../src/utils/next-element-sibling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAA;AAErC,MAAM,UAAU,kBAAkB,CAChC,IAAU,EACV,WAAmB,CAAC;IAEpB,IAAI,QAAQ,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAE/B,OAAO,QAAQ,CAAC,kBAAkB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AACpD,CAAC"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.nextSibling = void 0;
|
|
4
|
-
const ExtraDOM = require("extra-dom");
|
|
5
|
-
function nextSibling(node, distance = 1) {
|
|
1
|
+
import * as ExtraDOM from 'extra-dom';
|
|
2
|
+
export function nextSibling(node, distance = 1) {
|
|
6
3
|
if (distance === 0)
|
|
7
4
|
return node;
|
|
8
5
|
return ExtraDOM.nextSibling(node, distance);
|
|
9
6
|
}
|
|
10
|
-
exports.nextSibling = nextSibling;
|
|
11
7
|
//# sourceMappingURL=next-sibling.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-sibling.js","sourceRoot":"","sources":["../../src/utils/next-sibling.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"next-sibling.js","sourceRoot":"","sources":["../../src/utils/next-sibling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAA;AAErC,MAAM,UAAU,WAAW,CAAC,IAAU,EAAE,WAAmB,CAAC;IAC1D,IAAI,QAAQ,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAE/B,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blackglory/match",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A module for matching nodes from pages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"query",
|
|
@@ -11,53 +11,54 @@
|
|
|
11
11
|
"lib",
|
|
12
12
|
"src"
|
|
13
13
|
],
|
|
14
|
+
"type": "module",
|
|
14
15
|
"main": "lib/index.js",
|
|
15
16
|
"types": "lib/index.d.ts",
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=22"
|
|
20
|
+
},
|
|
16
21
|
"repository": "git@github.com:BlackGlory/match.git",
|
|
17
22
|
"author": "BlackGlory <woshenmedoubuzhidao@blackglory.me>",
|
|
18
23
|
"license": "MIT",
|
|
19
|
-
"sideEffects": false,
|
|
20
24
|
"scripts": {
|
|
25
|
+
"prepare": "ts-patch install -s",
|
|
21
26
|
"lint": "eslint --ext .js,.jsx,.ts,.tsx --quiet src __tests__",
|
|
22
|
-
"test": "
|
|
23
|
-
"
|
|
24
|
-
"prepublishOnly": "run-s clean build",
|
|
27
|
+
"test": "vitest --run",
|
|
28
|
+
"prepublishOnly": "run-s prepare clean build",
|
|
25
29
|
"clean": "rimraf lib",
|
|
26
|
-
"build": "
|
|
27
|
-
"build:compile": "tsc --project tsconfig.build.json --module commonjs --target es2018 --outDir lib",
|
|
28
|
-
"build:patch": "tscpaths -p tsconfig.build.json -s ./src -o ./lib",
|
|
30
|
+
"build": "tsc --project tsconfig.build.json",
|
|
29
31
|
"release": "standard-version"
|
|
30
32
|
},
|
|
31
33
|
"husky": {
|
|
32
34
|
"hooks": {
|
|
33
|
-
"pre-commit": "run-s lint build test",
|
|
35
|
+
"pre-commit": "run-s prepare lint build test",
|
|
34
36
|
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
35
37
|
}
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
38
|
-
"@commitlint/cli": "^
|
|
39
|
-
"@commitlint/config-conventional": "^
|
|
40
|
-
"@
|
|
41
|
-
"@types/jsdom": "^
|
|
42
|
-
"
|
|
43
|
-
"@typescript-eslint/parser": "^5.6.0",
|
|
44
|
-
"eslint": "^8.4.1",
|
|
40
|
+
"@commitlint/cli": "^20.3.1",
|
|
41
|
+
"@commitlint/config-conventional": "^20.3.1",
|
|
42
|
+
"@eslint/js": "^9.39.2",
|
|
43
|
+
"@types/jsdom": "^27.0.0",
|
|
44
|
+
"eslint": "^9.39.2",
|
|
45
45
|
"husky": "^4.3.8",
|
|
46
|
-
"iterable-operator": "^
|
|
47
|
-
"
|
|
48
|
-
"jsdom": "^19.0.0",
|
|
46
|
+
"iterable-operator": "^5.1.0",
|
|
47
|
+
"jsdom": "^27.4.0",
|
|
49
48
|
"npm-run-all": "^4.1.5",
|
|
50
|
-
"rimraf": "^
|
|
51
|
-
"standard-version": "^9.
|
|
52
|
-
"ts-
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"typescript": "^
|
|
49
|
+
"rimraf": "^6.1.2",
|
|
50
|
+
"standard-version": "^9.5.0",
|
|
51
|
+
"ts-patch": "^3.3.0",
|
|
52
|
+
"tslib": "^2.8.1",
|
|
53
|
+
"typescript": "^5.9.3",
|
|
54
|
+
"typescript-eslint": "^8.53.0",
|
|
55
|
+
"typescript-transform-paths": "^3.5.6",
|
|
56
|
+
"vite-tsconfig-paths": "^6.0.4",
|
|
57
|
+
"vitest": "^4.0.17"
|
|
56
58
|
},
|
|
57
59
|
"dependencies": {
|
|
58
|
-
"@blackglory/
|
|
59
|
-
"
|
|
60
|
-
"extra-
|
|
61
|
-
"extra-generator": "^0.2.15"
|
|
60
|
+
"@blackglory/prelude": "^0.4.0",
|
|
61
|
+
"extra-dom": "^0.7.0",
|
|
62
|
+
"extra-generator": "^0.5.9"
|
|
62
63
|
}
|
|
63
64
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { match } from './match'
|
|
2
|
-
export { matchElement } from './match-element'
|
|
1
|
+
export { match } from './match.js'
|
|
2
|
+
export { matchElement } from './match-element.js'
|
|
3
3
|
|
|
4
|
-
export { anyOf } from '@matchers/any-of'
|
|
5
|
-
export { childNodes } from '@matchers/child-nodes'
|
|
6
|
-
export { children } from '@matchers/children'
|
|
7
|
-
export { css } from '@matchers/css'
|
|
8
|
-
export { element } from '@matchers/element'
|
|
9
|
-
export { multiple } from '@matchers/multiple'
|
|
10
|
-
export { node } from '@matchers/node'
|
|
11
|
-
export { optional } from '@matchers/optional'
|
|
12
|
-
export { repeat } from '@matchers/repeat'
|
|
13
|
-
export { tap } from '@matchers/tap'
|
|
14
|
-
export { textContentEquals } from '@matchers/text-content-equals'
|
|
15
|
-
export { textContentIncludes } from '@matchers/text-content-includes'
|
|
16
|
-
export { textContentMatches } from '@matchers/text-content-matches'
|
|
17
|
-
export { textNode } from '@matchers/text-node'
|
|
18
|
-
export { xpath } from '@matchers/xpath'
|
|
4
|
+
export { anyOf } from '@matchers/any-of.js'
|
|
5
|
+
export { childNodes } from '@matchers/child-nodes.js'
|
|
6
|
+
export { children } from '@matchers/children.js'
|
|
7
|
+
export { css } from '@matchers/css.js'
|
|
8
|
+
export { element } from '@matchers/element.js'
|
|
9
|
+
export { multiple } from '@matchers/multiple.js'
|
|
10
|
+
export { node } from '@matchers/node.js'
|
|
11
|
+
export { optional } from '@matchers/optional.js'
|
|
12
|
+
export { repeat } from '@matchers/repeat.js'
|
|
13
|
+
export { tap } from '@matchers/tap.js'
|
|
14
|
+
export { textContentEquals } from '@matchers/text-content-equals.js'
|
|
15
|
+
export { textContentIncludes } from '@matchers/text-content-includes.js'
|
|
16
|
+
export { textContentMatches } from '@matchers/text-content-matches.js'
|
|
17
|
+
export { textNode } from '@matchers/text-node.js'
|
|
18
|
+
export { xpath } from '@matchers/xpath.js'
|
package/src/match-element.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isDocument } from 'extra-dom'
|
|
2
|
-
import { IMatcher, IContext } from './types'
|
|
3
|
-
import { matchOneByOne } from '@utils/match-one-by-one'
|
|
4
|
-
import { nextElementSibling } from '@utils/next-element-sibling'
|
|
2
|
+
import { IMatcher, IContext } from './types.js'
|
|
3
|
+
import { matchOneByOne } from '@utils/match-one-by-one.js'
|
|
4
|
+
import { nextElementSibling } from '@utils/next-element-sibling.js'
|
|
5
5
|
|
|
6
6
|
export function matchElement(
|
|
7
7
|
this: void | Document
|
package/src/match.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isDocument } from 'extra-dom'
|
|
2
|
-
import { IMatcher, IContext } from './types'
|
|
3
|
-
import { matchOneByOne } from '@utils/match-one-by-one'
|
|
4
|
-
import { nextSibling } from '@utils/next-sibling'
|
|
2
|
+
import { IMatcher, IContext } from './types.js'
|
|
3
|
+
import { matchOneByOne } from '@utils/match-one-by-one.js'
|
|
4
|
+
import { nextSibling } from '@utils/next-sibling.js'
|
|
5
5
|
|
|
6
6
|
export function match(
|
|
7
7
|
this: void | Document
|
package/src/matchers/any-of.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { INestedMatcher, IMatcher, IReadonlyContext } from '@src/types'
|
|
2
|
-
import { matchOneByOne } from '@utils/match-one-by-one'
|
|
3
|
-
import { mergeInPlace } from '@utils/merge-in-place'
|
|
4
|
-
import { nextSibling } from '@utils/next-sibling'
|
|
1
|
+
import { INestedMatcher, IMatcher, IReadonlyContext } from '@src/types.js'
|
|
2
|
+
import { matchOneByOne } from '@utils/match-one-by-one.js'
|
|
3
|
+
import { mergeInPlace } from '@utils/merge-in-place.js'
|
|
4
|
+
import { nextSibling } from '@utils/next-sibling.js'
|
|
5
5
|
|
|
6
6
|
export function childNodes(...matchers: Array<IMatcher<Node>>): INestedMatcher<Node> {
|
|
7
7
|
return function (this: IReadonlyContext, node: Node) {
|
package/src/matchers/children.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IMatcher, INestedMatcher, IReadonlyContext } from '@src/types'
|
|
2
|
-
import { matchOneByOne } from '@utils/match-one-by-one'
|
|
3
|
-
import { mergeInPlace } from '@utils/merge-in-place'
|
|
4
|
-
import { nextElementSibling } from '@utils/next-element-sibling'
|
|
1
|
+
import { IMatcher, INestedMatcher, IReadonlyContext } from '@src/types.js'
|
|
2
|
+
import { matchOneByOne } from '@utils/match-one-by-one.js'
|
|
3
|
+
import { mergeInPlace } from '@utils/merge-in-place.js'
|
|
4
|
+
import { nextElementSibling } from '@utils/next-element-sibling.js'
|
|
5
5
|
|
|
6
6
|
export function children(
|
|
7
7
|
...matchers: Array<IMatcher<Element>>
|
package/src/matchers/css.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { concat } from '@utils/concat'
|
|
2
|
-
import { ITerminalMatcher } from '@src/types'
|
|
3
|
-
import { isString } from '@blackglory/
|
|
1
|
+
import { concat } from '@utils/concat.js'
|
|
2
|
+
import { ITerminalMatcher } from '@src/types.js'
|
|
3
|
+
import { isString } from '@blackglory/prelude'
|
|
4
4
|
|
|
5
5
|
export function css(
|
|
6
6
|
strings: TemplateStringsArray
|
package/src/matchers/element.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isntElement } from 'extra-dom'
|
|
2
|
-
import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types'
|
|
3
|
-
import { isArray, isString } from '@blackglory/
|
|
4
|
-
import { concat } from '@utils/concat'
|
|
5
|
-
import { mergeInPlace } from '@utils/merge-in-place'
|
|
2
|
+
import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types.js'
|
|
3
|
+
import { isArray, isString } from '@blackglory/prelude'
|
|
4
|
+
import { concat } from '@utils/concat.js'
|
|
5
|
+
import { mergeInPlace } from '@utils/merge-in-place.js'
|
|
6
6
|
|
|
7
7
|
export function element(
|
|
8
8
|
strings: TemplateStringsArray
|
package/src/matchers/multiple.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { INestedMatcher, ITerminalMatcher, ISkipMatcher, IReadonlyContext } from '@src/types'
|
|
1
|
+
import { INestedMatcher, ITerminalMatcher, ISkipMatcher, IReadonlyContext } from '@src/types.js'
|
|
2
2
|
import { countup } from 'extra-generator'
|
|
3
|
-
import { assert } from '@blackglory/
|
|
4
|
-
import { matchMultiple } from '@utils/match-multiple'
|
|
3
|
+
import { assert } from '@blackglory/prelude'
|
|
4
|
+
import { matchMultiple } from '@utils/match-multiple.js'
|
|
5
5
|
|
|
6
6
|
export enum Range {
|
|
7
7
|
Min = 0
|
package/src/matchers/node.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types'
|
|
2
|
-
import { isArray, isString } from '@blackglory/
|
|
3
|
-
import { concat } from '@utils/concat'
|
|
4
|
-
import { mergeInPlace } from '@utils/merge-in-place'
|
|
1
|
+
import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types.js'
|
|
2
|
+
import { isArray, isString } from '@blackglory/prelude'
|
|
3
|
+
import { concat } from '@utils/concat.js'
|
|
4
|
+
import { mergeInPlace } from '@utils/merge-in-place.js'
|
|
5
5
|
|
|
6
6
|
export function node(
|
|
7
7
|
strings: TemplateStringsArray
|
package/src/matchers/optional.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { INestedMatcher, ITerminalMatcher, ISkipMatcher } from '@src/types'
|
|
2
|
-
import { multiple } from './multiple'
|
|
1
|
+
import { INestedMatcher, ITerminalMatcher, ISkipMatcher } from '@src/types.js'
|
|
2
|
+
import { multiple } from './multiple.js'
|
|
3
3
|
|
|
4
4
|
export function optional<T extends Node>(matcher: INestedMatcher<T> | ITerminalMatcher<T>): ISkipMatcher<T> {
|
|
5
5
|
return multiple([0, 1], matcher, { greedy: true })
|
package/src/matchers/repeat.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { INestedMatcher, ITerminalMatcher, ISkipMatcher, IReadonlyContext } from '@src/types'
|
|
2
|
-
import { assert } from '@blackglory/
|
|
3
|
-
import { matchMultiple } from '@utils/match-multiple'
|
|
1
|
+
import { INestedMatcher, ITerminalMatcher, ISkipMatcher, IReadonlyContext } from '@src/types.js'
|
|
2
|
+
import { assert } from '@blackglory/prelude'
|
|
3
|
+
import { matchMultiple } from '@utils/match-multiple.js'
|
|
4
4
|
|
|
5
5
|
export function repeat<T extends Node>(
|
|
6
6
|
times: number
|
package/src/matchers/tap.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types'
|
|
2
|
-
import { isArray, isString } from '@blackglory/
|
|
3
|
-
import { concat } from '@utils/concat'
|
|
1
|
+
import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types.js'
|
|
2
|
+
import { isArray, isString } from '@blackglory/prelude'
|
|
3
|
+
import { concat } from '@utils/concat.js'
|
|
4
4
|
import { isntTextNode } from 'extra-dom'
|
|
5
|
-
import { mergeInPlace } from '@utils/merge-in-place'
|
|
5
|
+
import { mergeInPlace } from '@utils/merge-in-place.js'
|
|
6
6
|
|
|
7
7
|
export function textNode(
|
|
8
8
|
strings: TemplateStringsArray
|
package/src/matchers/xpath.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ITerminalMatcher, IReadonlyContext } from '@src/types'
|
|
2
|
-
import { isString } from '@blackglory/
|
|
3
|
-
import { concat } from '@utils/concat'
|
|
4
|
-
import { assert } from '@blackglory/
|
|
1
|
+
import { ITerminalMatcher, IReadonlyContext } from '@src/types.js'
|
|
2
|
+
import { isString } from '@blackglory/prelude'
|
|
3
|
+
import { concat } from '@utils/concat.js'
|
|
4
|
+
import { assert } from '@blackglory/prelude'
|
|
5
5
|
|
|
6
6
|
const UNORDERED_NODE_ITERATOR_TYPE =
|
|
7
7
|
'XPathResult' in globalThis
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { countup } from 'extra-generator'
|
|
2
|
-
import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types'
|
|
2
|
+
import { INestedMatcher, ITerminalMatcher, IReadonlyContext } from '@src/types.js'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @returns {number} 返回值为成功匹配的元素个数, 当此值等于ubound时, 代表匹配成功.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IMatcher, IReadonlyContext } from '@src/types'
|
|
2
|
-
import { isBoolean, isNumber, isIterable } from '@blackglory/
|
|
1
|
+
import { IMatcher, IReadonlyContext } from '@src/types.js'
|
|
2
|
+
import { isBoolean, isNumber, isIterable } from '@blackglory/prelude'
|
|
3
3
|
|
|
4
4
|
export function matchOneByOne<T extends Node>(
|
|
5
5
|
context: IReadonlyContext
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { isArray } from '@blackglory/
|
|
1
|
+
import { isArray } from '@blackglory/prelude'
|
|
2
2
|
|
|
3
3
|
export function mergeInPlace<T>(
|
|
4
|
-
target:
|
|
5
|
-
, source:
|
|
4
|
+
target: Record<string, T | T[]>
|
|
5
|
+
, source: Record<string, T | T[]>
|
|
6
6
|
): void {
|
|
7
7
|
for (const [key, value] of Object.entries(source)) {
|
|
8
8
|
if (target[key]) {
|