@blackglory/match 0.3.3
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 +62 -0
- package/LICENSE +21 -0
- package/README.md +273 -0
- package/dist/es2015/index.min.mjs +2 -0
- package/dist/es2015/index.min.mjs.map +1 -0
- package/dist/es2015/index.mjs +3918 -0
- package/dist/es2015/index.mjs.map +1 -0
- package/dist/es2015/index.umd.js +3944 -0
- package/dist/es2015/index.umd.js.map +1 -0
- package/dist/es2015/index.umd.min.js +2 -0
- package/dist/es2015/index.umd.min.js.map +1 -0
- package/dist/es2018/index.min.mjs +2 -0
- package/dist/es2018/index.min.mjs.map +1 -0
- package/dist/es2018/index.mjs +3926 -0
- package/dist/es2018/index.mjs.map +1 -0
- package/dist/es2018/index.umd.js +3952 -0
- package/dist/es2018/index.umd.js.map +1 -0
- package/dist/es2018/index.umd.min.js +2 -0
- package/dist/es2018/index.umd.min.js.map +1 -0
- package/lib/es2015/index.d.ts +17 -0
- package/lib/es2015/index.js +38 -0
- package/lib/es2015/index.js.map +1 -0
- package/lib/es2015/match-element.d.ts +4 -0
- package/lib/es2015/match-element.js +22 -0
- package/lib/es2015/match-element.js.map +1 -0
- package/lib/es2015/match.d.ts +4 -0
- package/lib/es2015/match.js +22 -0
- package/lib/es2015/match.js.map +1 -0
- package/lib/es2015/matchers/any-of.d.ts +6 -0
- package/lib/es2015/matchers/any-of.js +10 -0
- package/lib/es2015/matchers/any-of.js.map +1 -0
- package/lib/es2015/matchers/child-nodes.d.ts +2 -0
- package/lib/es2015/matchers/child-nodes.js +23 -0
- package/lib/es2015/matchers/child-nodes.js.map +1 -0
- package/lib/es2015/matchers/children.d.ts +2 -0
- package/lib/es2015/matchers/children.js +23 -0
- package/lib/es2015/matchers/children.js.map +1 -0
- package/lib/es2015/matchers/css.d.ts +3 -0
- package/lib/es2015/matchers/css.js +18 -0
- package/lib/es2015/matchers/css.js.map +1 -0
- package/lib/es2015/matchers/element.d.ts +4 -0
- package/lib/es2015/matchers/element.js +34 -0
- package/lib/es2015/matchers/element.js.map +1 -0
- package/lib/es2015/matchers/multiple.d.ts +10 -0
- package/lib/es2015/matchers/multiple.js +42 -0
- package/lib/es2015/matchers/multiple.js.map +1 -0
- package/lib/es2015/matchers/node.d.ts +4 -0
- package/lib/es2015/matchers/node.js +31 -0
- package/lib/es2015/matchers/node.js.map +1 -0
- package/lib/es2015/matchers/optional.d.ts +2 -0
- package/lib/es2015/matchers/optional.js +9 -0
- package/lib/es2015/matchers/optional.js.map +1 -0
- package/lib/es2015/matchers/repeat.d.ts +2 -0
- package/lib/es2015/matchers/repeat.js +20 -0
- package/lib/es2015/matchers/repeat.js.map +1 -0
- package/lib/es2015/matchers/tap.d.ts +2 -0
- package/lib/es2015/matchers/tap.js +12 -0
- package/lib/es2015/matchers/tap.js.map +1 -0
- package/lib/es2015/matchers/text-content-equals.d.ts +7 -0
- package/lib/es2015/matchers/text-content-equals.js +20 -0
- package/lib/es2015/matchers/text-content-equals.js.map +1 -0
- package/lib/es2015/matchers/text-content-includes.d.ts +7 -0
- package/lib/es2015/matchers/text-content-includes.js +20 -0
- package/lib/es2015/matchers/text-content-includes.js.map +1 -0
- package/lib/es2015/matchers/text-content-matches.d.ts +6 -0
- package/lib/es2015/matchers/text-content-matches.js +16 -0
- package/lib/es2015/matchers/text-content-matches.js.map +1 -0
- package/lib/es2015/matchers/text-node.d.ts +4 -0
- package/lib/es2015/matchers/text-node.js +34 -0
- package/lib/es2015/matchers/text-node.js.map +1 -0
- package/lib/es2015/matchers/xpath.d.ts +3 -0
- package/lib/es2015/matchers/xpath.js +34 -0
- package/lib/es2015/matchers/xpath.js.map +1 -0
- package/lib/es2015/types.d.ts +18 -0
- package/lib/es2015/types.js +3 -0
- package/lib/es2015/types.js.map +1 -0
- package/lib/es2015/utils/concat.d.ts +1 -0
- package/lib/es2015/utils/concat.js +14 -0
- package/lib/es2015/utils/concat.js.map +1 -0
- package/lib/es2015/utils/match-multiple.d.ts +2 -0
- package/lib/es2015/utils/match-multiple.js +21 -0
- package/lib/es2015/utils/match-multiple.js.map +1 -0
- package/lib/es2015/utils/match-one-by-one.d.ts +2 -0
- package/lib/es2015/utils/match-one-by-one.js +38 -0
- package/lib/es2015/utils/match-one-by-one.js.map +1 -0
- package/lib/es2015/utils/merge.d.ts +5 -0
- package/lib/es2015/utils/merge.js +30 -0
- package/lib/es2015/utils/merge.js.map +1 -0
- package/lib/es2015/utils/next-element-sibling.d.ts +1 -0
- package/lib/es2015/utils/next-element-sibling.js +11 -0
- package/lib/es2015/utils/next-element-sibling.js.map +1 -0
- package/lib/es2015/utils/next-sibling.d.ts +1 -0
- package/lib/es2015/utils/next-sibling.js +11 -0
- package/lib/es2015/utils/next-sibling.js.map +1 -0
- package/lib/es2018/index.d.ts +17 -0
- package/lib/es2018/index.js +38 -0
- package/lib/es2018/index.js.map +1 -0
- package/lib/es2018/match-element.d.ts +4 -0
- package/lib/es2018/match-element.js +22 -0
- package/lib/es2018/match-element.js.map +1 -0
- package/lib/es2018/match.d.ts +4 -0
- package/lib/es2018/match.js +22 -0
- package/lib/es2018/match.js.map +1 -0
- package/lib/es2018/matchers/any-of.d.ts +6 -0
- package/lib/es2018/matchers/any-of.js +10 -0
- package/lib/es2018/matchers/any-of.js.map +1 -0
- package/lib/es2018/matchers/child-nodes.d.ts +2 -0
- package/lib/es2018/matchers/child-nodes.js +27 -0
- package/lib/es2018/matchers/child-nodes.js.map +1 -0
- package/lib/es2018/matchers/children.d.ts +2 -0
- package/lib/es2018/matchers/children.js +27 -0
- package/lib/es2018/matchers/children.js.map +1 -0
- package/lib/es2018/matchers/css.d.ts +3 -0
- package/lib/es2018/matchers/css.js +18 -0
- package/lib/es2018/matchers/css.js.map +1 -0
- package/lib/es2018/matchers/element.d.ts +4 -0
- package/lib/es2018/matchers/element.js +34 -0
- package/lib/es2018/matchers/element.js.map +1 -0
- package/lib/es2018/matchers/multiple.d.ts +10 -0
- package/lib/es2018/matchers/multiple.js +42 -0
- package/lib/es2018/matchers/multiple.js.map +1 -0
- package/lib/es2018/matchers/node.d.ts +4 -0
- package/lib/es2018/matchers/node.js +31 -0
- package/lib/es2018/matchers/node.js.map +1 -0
- package/lib/es2018/matchers/optional.d.ts +2 -0
- package/lib/es2018/matchers/optional.js +9 -0
- package/lib/es2018/matchers/optional.js.map +1 -0
- package/lib/es2018/matchers/repeat.d.ts +2 -0
- package/lib/es2018/matchers/repeat.js +20 -0
- package/lib/es2018/matchers/repeat.js.map +1 -0
- package/lib/es2018/matchers/tap.d.ts +2 -0
- package/lib/es2018/matchers/tap.js +12 -0
- package/lib/es2018/matchers/tap.js.map +1 -0
- package/lib/es2018/matchers/text-content-equals.d.ts +7 -0
- package/lib/es2018/matchers/text-content-equals.js +20 -0
- package/lib/es2018/matchers/text-content-equals.js.map +1 -0
- package/lib/es2018/matchers/text-content-includes.d.ts +7 -0
- package/lib/es2018/matchers/text-content-includes.js +20 -0
- package/lib/es2018/matchers/text-content-includes.js.map +1 -0
- package/lib/es2018/matchers/text-content-matches.d.ts +6 -0
- package/lib/es2018/matchers/text-content-matches.js +16 -0
- package/lib/es2018/matchers/text-content-matches.js.map +1 -0
- package/lib/es2018/matchers/text-node.d.ts +4 -0
- package/lib/es2018/matchers/text-node.js +34 -0
- package/lib/es2018/matchers/text-node.js.map +1 -0
- package/lib/es2018/matchers/xpath.d.ts +3 -0
- package/lib/es2018/matchers/xpath.js +34 -0
- package/lib/es2018/matchers/xpath.js.map +1 -0
- package/lib/es2018/types.d.ts +18 -0
- package/lib/es2018/types.js +3 -0
- package/lib/es2018/types.js.map +1 -0
- package/lib/es2018/utils/concat.d.ts +1 -0
- package/lib/es2018/utils/concat.js +14 -0
- package/lib/es2018/utils/concat.js.map +1 -0
- package/lib/es2018/utils/match-multiple.d.ts +2 -0
- package/lib/es2018/utils/match-multiple.js +21 -0
- package/lib/es2018/utils/match-multiple.js.map +1 -0
- package/lib/es2018/utils/match-one-by-one.d.ts +2 -0
- package/lib/es2018/utils/match-one-by-one.js +38 -0
- package/lib/es2018/utils/match-one-by-one.js.map +1 -0
- package/lib/es2018/utils/merge.d.ts +5 -0
- package/lib/es2018/utils/merge.js +30 -0
- package/lib/es2018/utils/merge.js.map +1 -0
- package/lib/es2018/utils/next-element-sibling.d.ts +1 -0
- package/lib/es2018/utils/next-element-sibling.js +11 -0
- package/lib/es2018/utils/next-element-sibling.js.map +1 -0
- package/lib/es2018/utils/next-sibling.d.ts +1 -0
- package/lib/es2018/utils/next-sibling.js +11 -0
- package/lib/es2018/utils/next-sibling.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.node = void 0;
|
|
4
|
+
const types_1 = require("@blackglory/types");
|
|
5
|
+
const concat_1 = require("../utils/concat");
|
|
6
|
+
const merge_1 = require("../utils/merge");
|
|
7
|
+
function node(...args) {
|
|
8
|
+
if (Array.isArray(args[0])) {
|
|
9
|
+
const [strings, ...values] = args;
|
|
10
|
+
const name = (0, concat_1.concat)(strings, values).join('');
|
|
11
|
+
return (...matchers) => node(name, ...matchers);
|
|
12
|
+
}
|
|
13
|
+
if ((0, types_1.isString)(args[0])) {
|
|
14
|
+
const [name, ...matchers] = args;
|
|
15
|
+
return function (_node) {
|
|
16
|
+
const result = node(...matchers).call(this, _node);
|
|
17
|
+
if (result) {
|
|
18
|
+
(0, merge_1.merge)(this.collection, { [name]: _node });
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const [...matchers] = args;
|
|
24
|
+
return function (node) {
|
|
25
|
+
if (matchers.length === 0)
|
|
26
|
+
return true;
|
|
27
|
+
return matchers.every(match => match.call(this, node));
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.node = node;
|
|
31
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/matchers/node.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAC5C,0CAAsC;AACtC,wCAAoC;AAapC,SAAgB,IAAI,CAAC,GAAG,IAG6C;IAEnE,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QAC1B,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,GACxB,IAA4D,CAAA;QAC9D,MAAM,IAAI,GAAG,IAAA,eAAM,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAE7C,OAAO,CAAC,GAAG,QAA8D,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAA;KACtG;IAED,IAAI,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QACrB,MAAM,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,GACvB,IAAyF,CAAA;QAE3F,OAAO,UAAkC,KAAW;YAClD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;YAClD,IAAI,MAAM,EAAE;gBACV,IAAA,aAAK,EAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;aAC1C;YACD,OAAO,MAAM,CAAA;QACf,CAAC,CAAA;KACF;IAED,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,IAA2E,CAAA;IAEjG,OAAO,UAAkC,IAAU;QACjD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QAEtC,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IACxD,CAAC,CAAA;AACH,CAAC;AAjCD,oBAiCC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.optional = void 0;
|
|
4
|
+
const multiple_1 = require("./multiple");
|
|
5
|
+
function optional(matcher) {
|
|
6
|
+
return (0, multiple_1.multiple)([0, 1], matcher, { greedy: true });
|
|
7
|
+
}
|
|
8
|
+
exports.optional = optional;
|
|
9
|
+
//# sourceMappingURL=optional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional.js","sourceRoot":"","sources":["../../../src/matchers/optional.ts"],"names":[],"mappings":";;;AACA,yCAAqC;AAErC,SAAgB,QAAQ,CAAiB,OAAgD;IACvF,OAAO,IAAA,mBAAQ,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;AACpD,CAAC;AAFD,4BAEC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.repeat = void 0;
|
|
4
|
+
const errors_1 = require("@blackglory/errors");
|
|
5
|
+
const match_multiple_1 = require("../utils/match-multiple");
|
|
6
|
+
function repeat(times, matcher) {
|
|
7
|
+
(0, errors_1.assert)(Number.isInteger(times), 'parameter times must be an integer');
|
|
8
|
+
(0, errors_1.assert)(times >= 0, 'parameter number must be greater than or equal to 0');
|
|
9
|
+
return function (node) {
|
|
10
|
+
const result = match_multiple_1.matchMultiple.call(this, node, times, matcher);
|
|
11
|
+
if (result === times) {
|
|
12
|
+
return times;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.repeat = repeat;
|
|
20
|
+
//# sourceMappingURL=repeat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repeat.js","sourceRoot":"","sources":["../../../src/matchers/repeat.ts"],"names":[],"mappings":";;;AACA,+CAA2C;AAC3C,0DAAqD;AAErD,SAAgB,MAAM,CACpB,KAAa,EACb,OAAgD;IAEhD,IAAA,eAAM,EAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,oCAAoC,CAAC,CAAA;IACrE,IAAA,eAAM,EAAC,KAAK,IAAI,CAAC,EAAE,qDAAqD,CAAC,CAAA;IAEzE,OAAO,UAAkC,IAAO;QAC9C,MAAM,MAAM,GAAG,8BAAa,CAAC,IAAI,CAC/B,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,OAAwD,CACzD,CAAA;QACD,IAAI,MAAM,KAAK,KAAK,EAAE;YACpB,OAAO,KAAK,CAAA;SACb;aAAM;YACL,OAAO,KAAK,CAAA;SACb;IACH,CAAC,CAAA;AACH,CAAC;AApBD,wBAoBC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tap = void 0;
|
|
4
|
+
function tap(matcher, callback) {
|
|
5
|
+
return function (node) {
|
|
6
|
+
const result = matcher.call(this, node);
|
|
7
|
+
callback(result);
|
|
8
|
+
return result;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
exports.tap = tap;
|
|
12
|
+
//# sourceMappingURL=tap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tap.js","sourceRoot":"","sources":["../../../src/matchers/tap.ts"],"names":[],"mappings":";;;AAEA,SAAgB,GAAG,CACjB,OAA+C,EAC/C,QAA4B;IAE5B,OAAO,UAAkC,IAAO;QAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACvC,QAAQ,CAAC,MAAM,CAAC,CAAA;QAChB,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;AACH,CAAC;AATD,kBASC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ITerminalMatcher } from '../types';
|
|
2
|
+
interface ITextContentEqualsOptions {
|
|
3
|
+
caseSensitive?: boolean;
|
|
4
|
+
trim?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function textContentEquals(text: string, { caseSensitive, trim }?: ITextContentEqualsOptions): ITerminalMatcher<Node>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textContentEquals = void 0;
|
|
4
|
+
const types_1 = require("@blackglory/types");
|
|
5
|
+
function textContentEquals(text, { caseSensitive = true, trim = false } = {}) {
|
|
6
|
+
return (node) => {
|
|
7
|
+
if ((0, types_1.isNull)(node.textContent))
|
|
8
|
+
return false;
|
|
9
|
+
let textContent = node.textContent;
|
|
10
|
+
if (!caseSensitive) {
|
|
11
|
+
textContent = textContent.toLowerCase();
|
|
12
|
+
text = text.toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
if (trim)
|
|
15
|
+
textContent = textContent.trim();
|
|
16
|
+
return textContent === text;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.textContentEquals = textContentEquals;
|
|
20
|
+
//# sourceMappingURL=text-content-equals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-content-equals.js","sourceRoot":"","sources":["../../../src/matchers/text-content-equals.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAO1C,SAAgB,iBAAiB,CAC/B,IAAY,EACZ,EACE,aAAa,GAAG,IAAI,EACpB,IAAI,GAAG,KAAK,KACiB,EAAE;IAEjC,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,IAAI,IAAA,cAAM,EAAC,IAAI,CAAC,WAAW,CAAC;YAAE,OAAO,KAAK,CAAA;QAE1C,IAAI,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QAClC,IAAI,CAAC,aAAa,EAAE;YAClB,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,CAAA;YACvC,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;SAC1B;QACD,IAAI,IAAI;YAAE,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,CAAA;QAE1C,OAAO,WAAW,KAAK,IAAI,CAAA;IAC7B,CAAC,CAAA;AACH,CAAC;AAnBD,8CAmBC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ITerminalMatcher } from '../types';
|
|
2
|
+
interface ITextContentIncludesOptions {
|
|
3
|
+
caseSensitive?: boolean;
|
|
4
|
+
trim?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function textContentIncludes(searchString: string, { caseSensitive, trim }?: ITextContentIncludesOptions): ITerminalMatcher<Node>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textContentIncludes = void 0;
|
|
4
|
+
const types_1 = require("@blackglory/types");
|
|
5
|
+
function textContentIncludes(searchString, { caseSensitive = true, trim = false } = {}) {
|
|
6
|
+
return (node) => {
|
|
7
|
+
if ((0, types_1.isNull)(node.textContent))
|
|
8
|
+
return false;
|
|
9
|
+
let textContent = node.textContent;
|
|
10
|
+
if (!caseSensitive) {
|
|
11
|
+
textContent = textContent.toLowerCase();
|
|
12
|
+
searchString = searchString.toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
if (trim)
|
|
15
|
+
textContent = textContent.trim();
|
|
16
|
+
return textContent.includes(searchString);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.textContentIncludes = textContentIncludes;
|
|
20
|
+
//# sourceMappingURL=text-content-includes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-content-includes.js","sourceRoot":"","sources":["../../../src/matchers/text-content-includes.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAO1C,SAAgB,mBAAmB,CACjC,YAAoB,EACpB,EACE,aAAa,GAAG,IAAI,EACpB,IAAI,GAAG,KAAK,KACmB,EAAE;IAEnC,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,IAAI,IAAA,cAAM,EAAC,IAAI,CAAC,WAAW,CAAC;YAAE,OAAO,KAAK,CAAA;QAE1C,IAAI,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QAClC,IAAI,CAAC,aAAa,EAAE;YAClB,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,CAAA;YACvC,YAAY,GAAG,YAAY,CAAC,WAAW,EAAE,CAAA;SAC1C;QACD,IAAI,IAAI;YAAE,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,CAAA;QAE1C,OAAO,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAA;IAC3C,CAAC,CAAA;AACH,CAAC;AAnBD,kDAmBC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textContentMatches = void 0;
|
|
4
|
+
const types_1 = require("@blackglory/types");
|
|
5
|
+
function textContentMatches(pattern, { trim = false } = {}) {
|
|
6
|
+
return (node) => {
|
|
7
|
+
if ((0, types_1.isNull)(node.textContent))
|
|
8
|
+
return false;
|
|
9
|
+
let textContent = node.textContent;
|
|
10
|
+
if (trim)
|
|
11
|
+
textContent = textContent.trim();
|
|
12
|
+
return pattern.test(textContent);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.textContentMatches = textContentMatches;
|
|
16
|
+
//# sourceMappingURL=text-content-matches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-content-matches.js","sourceRoot":"","sources":["../../../src/matchers/text-content-matches.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAM1C,SAAgB,kBAAkB,CAChC,OAAe,EACf,EAAE,IAAI,GAAG,KAAK,KAAiC,EAAE;IAEjD,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,IAAI,IAAA,cAAM,EAAC,IAAI,CAAC,WAAW,CAAC;YAAE,OAAO,KAAK,CAAA;QAE1C,IAAI,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QAClC,IAAI,IAAI;YAAE,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,CAAA;QAE1C,OAAO,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAClC,CAAC,CAAA;AACH,CAAC;AAZD,gDAYC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { INestedMatcher, ITerminalMatcher } from '../types';
|
|
2
|
+
export declare function textNode(strings: TemplateStringsArray, ...values: string[]): (...matchers: Array<ITerminalMatcher<Node>>) => INestedMatcher<Node>;
|
|
3
|
+
export declare function textNode(name: string, ...matchers: Array<ITerminalMatcher<Node>>): INestedMatcher<Node>;
|
|
4
|
+
export declare function textNode(...matchers: Array<ITerminalMatcher<Node>>): INestedMatcher<Node>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textNode = void 0;
|
|
4
|
+
const types_1 = require("@blackglory/types");
|
|
5
|
+
const concat_1 = require("../utils/concat");
|
|
6
|
+
const extra_dom_1 = require("extra-dom");
|
|
7
|
+
const merge_1 = require("../utils/merge");
|
|
8
|
+
function textNode(...args) {
|
|
9
|
+
if (Array.isArray(args[0])) {
|
|
10
|
+
const [strings, ...values] = args;
|
|
11
|
+
const name = (0, concat_1.concat)(strings, values).join('');
|
|
12
|
+
return (...matchers) => textNode(name, ...matchers);
|
|
13
|
+
}
|
|
14
|
+
if ((0, types_1.isString)(args[0])) {
|
|
15
|
+
const [name, ...matchers] = args;
|
|
16
|
+
return function (node) {
|
|
17
|
+
const result = textNode(...matchers).call(this, node);
|
|
18
|
+
if (result) {
|
|
19
|
+
(0, merge_1.merge)(this.collection, { [name]: node });
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const [...matchers] = args;
|
|
25
|
+
return function (node) {
|
|
26
|
+
if ((0, extra_dom_1.isntTextNode)(node))
|
|
27
|
+
return false;
|
|
28
|
+
if (matchers.length === 0)
|
|
29
|
+
return true;
|
|
30
|
+
return matchers.every(match => match.call(this, node));
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.textNode = textNode;
|
|
34
|
+
//# sourceMappingURL=text-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-node.js","sourceRoot":"","sources":["../../../src/matchers/text-node.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAC5C,0CAAsC;AACtC,yCAAwC;AACxC,wCAAoC;AAapC,SAAgB,QAAQ,CAAC,GAAG,IAGkB;IAE5C,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QAC1B,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,GACxB,IAA4D,CAAA;QAC9D,MAAM,IAAI,GAAG,IAAA,eAAM,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAE7C,OAAO,CAAC,GAAG,QAAuC,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAA;KACnF;IAED,IAAI,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QACrB,MAAM,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,GACvB,IAAkE,CAAA;QAEpE,OAAO,UAAkC,IAAU;YACjD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YACrD,IAAI,MAAM,EAAE;gBACV,IAAA,aAAK,EAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;aACzC;YACD,OAAO,MAAM,CAAA;QACf,CAAC,CAAA;KACF;IAED,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,IAAoD,CAAA;IAE1E,OAAO,UAAkC,IAAU;QACjD,IAAI,IAAA,wBAAY,EAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAA;QACpC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QAEtC,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IACxD,CAAC,CAAA;AACH,CAAC;AAlCD,4BAkCC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.xpath = void 0;
|
|
4
|
+
const types_1 = require("@blackglory/types");
|
|
5
|
+
const concat_1 = require("../utils/concat");
|
|
6
|
+
const errors_1 = require("@blackglory/errors");
|
|
7
|
+
const UNORDERED_NODE_ITERATOR_TYPE = 'XPathResult' in globalThis
|
|
8
|
+
? XPathResult.UNORDERED_NODE_ITERATOR_TYPE
|
|
9
|
+
: 4;
|
|
10
|
+
function xpath(...args) {
|
|
11
|
+
if ((0, types_1.isString)(args[0])) {
|
|
12
|
+
const [expression] = args;
|
|
13
|
+
(0, errors_1.assert)(expression.startsWith('//*'), 'XPath expressions must start with "//*"');
|
|
14
|
+
return function (node) {
|
|
15
|
+
return xpathMatches(this.document, expression, node);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
const [strings, ...values] = args;
|
|
20
|
+
const expression = (0, concat_1.concat)(strings, values).join('');
|
|
21
|
+
return xpath(expression);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.xpath = xpath;
|
|
25
|
+
function xpathMatches(document, expression, node) {
|
|
26
|
+
const iterator = document.evaluate(expression, node, null, UNORDERED_NODE_ITERATOR_TYPE, null);
|
|
27
|
+
let value;
|
|
28
|
+
while ((value = iterator.iterateNext()) !== null) {
|
|
29
|
+
if (value === node)
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=xpath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xpath.js","sourceRoot":"","sources":["../../../src/matchers/xpath.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAC5C,0CAAsC;AACtC,+CAA2C;AAE3C,MAAM,4BAA4B,GAChC,aAAa,IAAI,UAAU;IAC3B,CAAC,CAAC,WAAW,CAAC,4BAA4B;IAC1C,CAAC,CAAC,CAAC,CAAA;AASL,SAAgB,KAAK,CAAC,GAAG,IAE6B;IAEpD,IAAI,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QACrB,MAAM,CAAC,UAAU,CAAC,GAAG,IAAI,CAAA;QACzB,IAAA,eAAM,EAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,yCAAyC,CAAC,CAAA;QAE/E,OAAO,UAEL,IAAU;YAEV,OAAO,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;QACtD,CAAC,CAAA;KACF;SAAM;QACL,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,GAAG,IAAI,CAAA;QACjC,MAAM,UAAU,GAAG,IAAA,eAAM,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAEnD,OAAO,KAAK,CAAC,UAAU,CAAC,CAAA;KACzB;AACH,CAAC;AApBD,sBAoBC;AAED,SAAS,YAAY,CAAC,QAAkB,EAAE,UAAkB,EAAE,IAAU;IACtE,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAChC,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,4BAA4B,EAC5B,IAAI,CACL,CAAA;IAED,IAAI,KAAK,CAAA;IACT,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,IAAI,EAAE;QAChD,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,IAAI,CAAA;KAChC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface IContext {
|
|
2
|
+
readonly document: Document;
|
|
3
|
+
readonly next: (node: Node, distance?: number) => Node | undefined;
|
|
4
|
+
readonly collection: {
|
|
5
|
+
[name: string]: Node | Node[];
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export interface IReadonlyContext {
|
|
9
|
+
readonly document: Document;
|
|
10
|
+
readonly next: (node: Node, distance?: number) => Node | undefined;
|
|
11
|
+
readonly collection: {
|
|
12
|
+
readonly [name: string]: Node | Node[];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare type IMatcher<T extends Node> = ITerminalMatcher<T> | INestedMatcher<T> | ISkipMatcher<T> | (<T extends Node>(this: IReadonlyContext, node: T) => boolean | number | Iterable<number>);
|
|
16
|
+
export declare type INestedMatcher<T extends Node> = (this: IReadonlyContext, node: T) => boolean;
|
|
17
|
+
export declare type ISkipMatcher<T extends Node> = (this: IReadonlyContext, node: T) => number | Iterable<number> | false;
|
|
18
|
+
export declare type ITerminalMatcher<T extends Node> = (this: IReadonlyContext, node: T) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function concat(strings: TemplateStringsArray, values: string[]): string[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.concat = void 0;
|
|
4
|
+
function concat(strings, values) {
|
|
5
|
+
const result = [];
|
|
6
|
+
for (let i = 0, len = values.length; i < len; i++) {
|
|
7
|
+
result.push(strings[i]);
|
|
8
|
+
result.push(values[i]);
|
|
9
|
+
}
|
|
10
|
+
result.push(strings[strings.length - 1]);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
exports.concat = concat;
|
|
14
|
+
//# sourceMappingURL=concat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concat.js","sourceRoot":"","sources":["../../../src/utils/concat.ts"],"names":[],"mappings":";;;AAAA,SAAgB,MAAM,CAAC,OAA6B,EAAE,MAAgB;IACpE,MAAM,MAAM,GAAG,EAAE,CAAA;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QACjD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;QACvB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;KACvB;IACD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAA;IACxC,OAAO,MAAM,CAAA;AACf,CAAC;AARD,wBAQC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchMultiple = void 0;
|
|
4
|
+
const extra_generator_1 = require("extra-generator");
|
|
5
|
+
function matchMultiple(node, ubound, matcher) {
|
|
6
|
+
let currentNode = node;
|
|
7
|
+
for (const round of (0, extra_generator_1.countup)(1, ubound)) {
|
|
8
|
+
if (!currentNode)
|
|
9
|
+
return round - 1;
|
|
10
|
+
const result = matcher.call(this, currentNode);
|
|
11
|
+
if (result) {
|
|
12
|
+
currentNode = this.next(currentNode);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return round - 1;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return ubound;
|
|
19
|
+
}
|
|
20
|
+
exports.matchMultiple = matchMultiple;
|
|
21
|
+
//# sourceMappingURL=match-multiple.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-multiple.js","sourceRoot":"","sources":["../../../src/utils/match-multiple.ts"],"names":[],"mappings":";;;AAAA,qDAAyC;AAMzC,SAAgB,aAAa,CAE3B,IAAO,EACP,MAAc,EACd,OAAgD;IAEhD,IAAI,WAAW,GAAa,IAAI,CAAA;IAEhC,KAAK,MAAM,KAAK,IAAI,IAAA,yBAAO,EAAC,CAAC,EAAE,MAAM,CAAC,EAAE;QACtC,IAAI,CAAC,WAAW;YAAE,OAAO,KAAK,GAAG,CAAC,CAAA;QAElC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;QAC9C,IAAI,MAAM,EAAE;YACV,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAa,CAAA;SACjD;aAAM;YACL,OAAO,KAAK,GAAG,CAAC,CAAA;SACjB;KACF;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AApBD,sCAoBC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchOneByOne = void 0;
|
|
4
|
+
const types_1 = require("@blackglory/types");
|
|
5
|
+
function matchOneByOne(context, source, ...matchers) {
|
|
6
|
+
if (matchers.length === 0)
|
|
7
|
+
return true;
|
|
8
|
+
if (!source)
|
|
9
|
+
return false;
|
|
10
|
+
const [matcher, ...otherMatchers] = matchers;
|
|
11
|
+
const result = Reflect.apply(matcher, context, [source]);
|
|
12
|
+
if ((0, types_1.isBoolean)(result)) {
|
|
13
|
+
if (result) {
|
|
14
|
+
const nextNode = context.next(source);
|
|
15
|
+
return matchOneByOne(context, nextNode, ...otherMatchers);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if ((0, types_1.isNumber)(result)) {
|
|
22
|
+
const distance = result;
|
|
23
|
+
const nextNode = context.next(source, distance);
|
|
24
|
+
return matchOneByOne(context, nextNode, ...otherMatchers);
|
|
25
|
+
}
|
|
26
|
+
if ((0, types_1.isIterable)(result)) {
|
|
27
|
+
for (const distance of result) {
|
|
28
|
+
const nextNode = context.next(source, distance);
|
|
29
|
+
if (matchOneByOne(context, nextNode, ...otherMatchers)) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
throw new Error('Unknown return value');
|
|
36
|
+
}
|
|
37
|
+
exports.matchOneByOne = matchOneByOne;
|
|
38
|
+
//# sourceMappingURL=match-one-by-one.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-one-by-one.js","sourceRoot":"","sources":["../../../src/utils/match-one-by-one.ts"],"names":[],"mappings":";;;AACA,6CAAmE;AAEnE,SAAgB,aAAa,CAC3B,OAAyB,EACzB,MAAgB,EAChB,GAAG,QAA4B;IAE/B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACtC,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IAEzB,MAAM,CAAC,OAAO,EAAE,GAAG,aAAa,CAAC,GAAG,QAAQ,CAAA;IAE5C,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,CAA+B,CAAA;IAGtF,IAAI,IAAA,iBAAS,EAAC,MAAM,CAAC,EAAE;QACrB,IAAI,MAAM,EAAE;YACV,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAa,CAAA;YACjD,OAAO,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC,CAAA;SAC1D;aAAM;YACL,OAAO,KAAK,CAAA;SACb;KACF;IAGD,IAAI,IAAA,gBAAQ,EAAC,MAAM,CAAC,EAAE;QACpB,MAAM,QAAQ,GAAG,MAAM,CAAA;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAa,CAAA;QAC3D,OAAO,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC,CAAA;KAC1D;IAGD,IAAI,IAAA,kBAAU,EAAC,MAAM,CAAC,EAAE;QACtB,KAAK,MAAM,QAAQ,IAAI,MAAM,EAAE;YAC7B,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAa,CAAA;YAC3D,IAAI,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC,EAAE;gBACtD,OAAO,IAAI,CAAA;aACZ;SACF;QAGD,OAAO,KAAK,CAAA;KACb;IAED,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;AACzC,CAAC;AA3CD,sCA2CC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.merge = void 0;
|
|
4
|
+
function merge(target, source) {
|
|
5
|
+
for (const [key, value] of Object.entries(source)) {
|
|
6
|
+
if (target[key]) {
|
|
7
|
+
if (Array.isArray(target[key])) {
|
|
8
|
+
if (Array.isArray(value)) {
|
|
9
|
+
target[key] = [...target[key], ...value];
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
target[key] = [...target[key], value];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
if (Array.isArray(value)) {
|
|
17
|
+
target[key] = [target[key], ...value];
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
target[key] = [target[key], value];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
target[key] = value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.merge = merge;
|
|
30
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../src/utils/merge.ts"],"names":[],"mappings":";;;AAAA,SAAgB,KAAK,CACnB,MAAkC,EAClC,MAAkC;IAElC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACjD,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE;YACf,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;gBAC9B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;oBACxB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAQ,EAAE,GAAG,KAAK,CAAC,CAAA;iBAChD;qBAAM;oBACL,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAQ,EAAE,KAAK,CAAC,CAAA;iBAC7C;aACF;iBAAM;gBACL,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;oBACxB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAM,EAAE,GAAG,KAAK,CAAC,CAAA;iBAC3C;qBAAM;oBACL,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAM,EAAE,KAAK,CAAC,CAAA;iBACxC;aACF;SACF;aAAM;YACL,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SACpB;KACF;AACH,CAAC;AAvBD,sBAuBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function nextElementSibling(node: Node, distance?: number): Node | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nextElementSibling = void 0;
|
|
4
|
+
const ExtraDOM = require("extra-dom");
|
|
5
|
+
function nextElementSibling(node, distance = 1) {
|
|
6
|
+
if (distance === 0)
|
|
7
|
+
return node;
|
|
8
|
+
return ExtraDOM.nextElementSibling(node, distance);
|
|
9
|
+
}
|
|
10
|
+
exports.nextElementSibling = nextElementSibling;
|
|
11
|
+
//# sourceMappingURL=next-element-sibling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-element-sibling.js","sourceRoot":"","sources":["../../../src/utils/next-element-sibling.ts"],"names":[],"mappings":";;;AAAA,sCAAqC;AAErC,SAAgB,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;AAPD,gDAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function nextSibling(node: Node, distance?: number): Node | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nextSibling = void 0;
|
|
4
|
+
const ExtraDOM = require("extra-dom");
|
|
5
|
+
function nextSibling(node, distance = 1) {
|
|
6
|
+
if (distance === 0)
|
|
7
|
+
return node;
|
|
8
|
+
return ExtraDOM.nextSibling(node, distance);
|
|
9
|
+
}
|
|
10
|
+
exports.nextSibling = nextSibling;
|
|
11
|
+
//# sourceMappingURL=next-sibling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-sibling.js","sourceRoot":"","sources":["../../../src/utils/next-sibling.ts"],"names":[],"mappings":";;;AAAA,sCAAqC;AAErC,SAAgB,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;AAJD,kCAIC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blackglory/match",
|
|
3
|
+
"version": "0.3.3",
|
|
4
|
+
"description": "A module for matching nodes from pages",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"query",
|
|
7
|
+
"css",
|
|
8
|
+
"xpath"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
"lib",
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"main": "lib/es2018/index.js",
|
|
15
|
+
"types": "lib/es2018/index.d.ts",
|
|
16
|
+
"repository": "git@github.com:BlackGlory/match.git",
|
|
17
|
+
"author": "BlackGlory <woshenmedoubuzhidao@blackglory.me>",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"lint": "eslint --ext .js,.jsx,.ts,.tsx --quiet src __tests__",
|
|
21
|
+
"test": "jest --config jest.config.js",
|
|
22
|
+
"test:coverage": "jest --coverage --config jest.config.js",
|
|
23
|
+
"prepublishOnly": "run-s clean build bundle",
|
|
24
|
+
"clean": "run-p clean:*",
|
|
25
|
+
"clean:build": "rimraf lib",
|
|
26
|
+
"clean:bundle": "rimraf dist",
|
|
27
|
+
"build": "run-p build:*",
|
|
28
|
+
"build:es2015": "run-s build:es2015:*",
|
|
29
|
+
"build:es2015:compile": "tsc --project tsconfig.build.json --module commonjs --target es2015 --outDir lib/es2015",
|
|
30
|
+
"build:es2015:patch": "tscpaths -p tsconfig.build.json -s ./src -o ./lib/es2015",
|
|
31
|
+
"build:es2018": "run-s build:es2018:*",
|
|
32
|
+
"build:es2018:compile": "tsc --project tsconfig.build.json --module commonjs --target es2018 --outDir lib/es2018",
|
|
33
|
+
"build:es2018:patch": "tscpaths -p tsconfig.build.json -s ./src -o ./lib/es2018",
|
|
34
|
+
"bundle": "rollup --config rollup.config.js",
|
|
35
|
+
"release": "standard-version"
|
|
36
|
+
},
|
|
37
|
+
"husky": {
|
|
38
|
+
"hooks": {
|
|
39
|
+
"pre-commit": "run-s lint build test",
|
|
40
|
+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@blackglory/jest-matchers": "^0.1.21",
|
|
45
|
+
"@commitlint/cli": "^13.2.1",
|
|
46
|
+
"@commitlint/config-conventional": "^13.2.0",
|
|
47
|
+
"@rollup/plugin-commonjs": "^21.0.0",
|
|
48
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
49
|
+
"@rollup/plugin-node-resolve": "^13.0.5",
|
|
50
|
+
"@rollup/plugin-replace": "^3.0.0",
|
|
51
|
+
"@rollup/plugin-typescript": "^8.2.5",
|
|
52
|
+
"@types/jest": "^27.0.2",
|
|
53
|
+
"@types/jsdom": "^16.2.13",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
55
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
56
|
+
"eslint": "^8.0.1",
|
|
57
|
+
"husky": "^4.3.8",
|
|
58
|
+
"iterable-operator": "^0.14.4",
|
|
59
|
+
"jest": "^27.2.5",
|
|
60
|
+
"jsdom": "^18.0.0",
|
|
61
|
+
"npm-run-all": "^4.1.5",
|
|
62
|
+
"rimraf": "^3.0.2",
|
|
63
|
+
"rollup": "^2.58.0",
|
|
64
|
+
"rollup-plugin-analyzer": "^4.0.0",
|
|
65
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
66
|
+
"standard-version": "^9.3.1",
|
|
67
|
+
"ts-jest": "^27.0.5",
|
|
68
|
+
"tscpaths": "^0.0.9",
|
|
69
|
+
"tslib": "^2.3.1",
|
|
70
|
+
"typescript": "^4.4.4"
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@blackglory/errors": "^1.1.2",
|
|
74
|
+
"@blackglory/types": "^0.5.1",
|
|
75
|
+
"extra-dom": "^0.4.3",
|
|
76
|
+
"extra-generator": "^0.2.11"
|
|
77
|
+
}
|
|
78
|
+
}
|