@depup/cheerio 1.2.0-depup.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.
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/Readme.md +229 -0
- package/changes.json +30 -0
- package/dist/browser/api/attributes.d.ts +385 -0
- package/dist/browser/api/attributes.d.ts.map +1 -0
- package/dist/browser/api/attributes.js +636 -0
- package/dist/browser/api/attributes.js.map +1 -0
- package/dist/browser/api/css.d.ts +42 -0
- package/dist/browser/api/css.d.ts.map +1 -0
- package/dist/browser/api/css.js +116 -0
- package/dist/browser/api/css.js.map +1 -0
- package/dist/browser/api/extract.d.ts +27 -0
- package/dist/browser/api/extract.d.ts.map +1 -0
- package/dist/browser/api/extract.js +42 -0
- package/dist/browser/api/extract.js.map +1 -0
- package/dist/browser/api/forms.d.ts +36 -0
- package/dist/browser/api/forms.d.ts.map +1 -0
- package/dist/browser/api/forms.js +81 -0
- package/dist/browser/api/forms.js.map +1 -0
- package/dist/browser/api/manipulation.d.ts +528 -0
- package/dist/browser/api/manipulation.d.ts.map +1 -0
- package/dist/browser/api/manipulation.js +831 -0
- package/dist/browser/api/manipulation.js.map +1 -0
- package/dist/browser/api/traversing.d.ts +657 -0
- package/dist/browser/api/traversing.d.ts.map +1 -0
- package/dist/browser/api/traversing.js +857 -0
- package/dist/browser/api/traversing.js.map +1 -0
- package/dist/browser/cheerio.d.ts +85 -0
- package/dist/browser/cheerio.d.ts.map +1 -0
- package/dist/browser/cheerio.js +58 -0
- package/dist/browser/cheerio.js.map +1 -0
- package/dist/browser/index-browser.d.mts.map +1 -0
- package/dist/browser/index-browser.mjs.map +1 -0
- package/dist/browser/index.d.ts +5 -0
- package/dist/browser/index.js +3 -0
- package/dist/browser/load-parse.d.ts +20 -0
- package/dist/browser/load-parse.d.ts.map +1 -0
- package/dist/browser/load-parse.js +28 -0
- package/dist/browser/load-parse.js.map +1 -0
- package/dist/browser/load.d.ts +91 -0
- package/dist/browser/load.d.ts.map +1 -0
- package/dist/browser/load.js +129 -0
- package/dist/browser/load.js.map +1 -0
- package/dist/browser/options.d.ts +98 -0
- package/dist/browser/options.d.ts.map +1 -0
- package/dist/browser/options.js +34 -0
- package/dist/browser/options.js.map +1 -0
- package/dist/browser/package.json +3 -0
- package/dist/browser/parse.d.ts +18 -0
- package/dist/browser/parse.d.ts.map +1 -0
- package/dist/browser/parse.js +73 -0
- package/dist/browser/parse.js.map +1 -0
- package/dist/browser/parsers/parse5-adapter.d.ts +20 -0
- package/dist/browser/parsers/parse5-adapter.d.ts.map +1 -0
- package/dist/browser/parsers/parse5-adapter.js +50 -0
- package/dist/browser/parsers/parse5-adapter.js.map +1 -0
- package/dist/browser/slim.d.ts +25 -0
- package/dist/browser/slim.d.ts.map +1 -0
- package/dist/browser/slim.js +22 -0
- package/dist/browser/slim.js.map +1 -0
- package/dist/browser/static.d.ts +112 -0
- package/dist/browser/static.d.ts.map +1 -0
- package/dist/browser/static.js +204 -0
- package/dist/browser/static.js.map +1 -0
- package/dist/browser/types.d.ts +21 -0
- package/dist/browser/types.d.ts.map +1 -0
- package/dist/browser/types.js +3 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/browser/utils.d.ts +55 -0
- package/dist/browser/utils.d.ts.map +1 -0
- package/dist/browser/utils.js +84 -0
- package/dist/browser/utils.js.map +1 -0
- package/dist/commonjs/api/attributes.d.ts +385 -0
- package/dist/commonjs/api/attributes.d.ts.map +1 -0
- package/dist/commonjs/api/attributes.js +647 -0
- package/dist/commonjs/api/attributes.js.map +1 -0
- package/dist/commonjs/api/css.d.ts +42 -0
- package/dist/commonjs/api/css.d.ts.map +1 -0
- package/dist/commonjs/api/css.js +119 -0
- package/dist/commonjs/api/css.js.map +1 -0
- package/dist/commonjs/api/extract.d.ts +27 -0
- package/dist/commonjs/api/extract.d.ts.map +1 -0
- package/dist/commonjs/api/extract.js +45 -0
- package/dist/commonjs/api/extract.js.map +1 -0
- package/dist/commonjs/api/forms.d.ts +36 -0
- package/dist/commonjs/api/forms.d.ts.map +1 -0
- package/dist/commonjs/api/forms.js +85 -0
- package/dist/commonjs/api/forms.js.map +1 -0
- package/dist/commonjs/api/manipulation.d.ts +528 -0
- package/dist/commonjs/api/manipulation.d.ts.map +1 -0
- package/dist/commonjs/api/manipulation.js +850 -0
- package/dist/commonjs/api/manipulation.js.map +1 -0
- package/dist/commonjs/api/traversing.d.ts +657 -0
- package/dist/commonjs/api/traversing.d.ts.map +1 -0
- package/dist/commonjs/api/traversing.js +914 -0
- package/dist/commonjs/api/traversing.js.map +1 -0
- package/dist/commonjs/cheerio.d.ts +85 -0
- package/dist/commonjs/cheerio.d.ts.map +1 -0
- package/dist/commonjs/cheerio.js +95 -0
- package/dist/commonjs/cheerio.js.map +1 -0
- package/dist/commonjs/index.d.ts +104 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +250 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/load-parse.d.ts +20 -0
- package/dist/commonjs/load-parse.d.ts.map +1 -0
- package/dist/commonjs/load-parse.js +34 -0
- package/dist/commonjs/load-parse.js.map +1 -0
- package/dist/commonjs/load.d.ts +91 -0
- package/dist/commonjs/load.d.ts.map +1 -0
- package/dist/commonjs/load.js +165 -0
- package/dist/commonjs/load.js.map +1 -0
- package/dist/commonjs/options.d.ts +98 -0
- package/dist/commonjs/options.d.ts.map +1 -0
- package/dist/commonjs/options.js +37 -0
- package/dist/commonjs/options.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/parse.d.ts +18 -0
- package/dist/commonjs/parse.d.ts.map +1 -0
- package/dist/commonjs/parse.js +77 -0
- package/dist/commonjs/parse.js.map +1 -0
- package/dist/commonjs/parsers/parse5-adapter.d.ts +20 -0
- package/dist/commonjs/parsers/parse5-adapter.d.ts.map +1 -0
- package/dist/commonjs/parsers/parse5-adapter.js +54 -0
- package/dist/commonjs/parsers/parse5-adapter.js.map +1 -0
- package/dist/commonjs/slim.d.ts +25 -0
- package/dist/commonjs/slim.d.ts.map +1 -0
- package/dist/commonjs/slim.js +30 -0
- package/dist/commonjs/slim.js.map +1 -0
- package/dist/commonjs/static.d.ts +112 -0
- package/dist/commonjs/static.d.ts.map +1 -0
- package/dist/commonjs/static.js +214 -0
- package/dist/commonjs/static.js.map +1 -0
- package/dist/commonjs/types.d.ts +21 -0
- package/dist/commonjs/types.d.ts.map +1 -0
- package/dist/commonjs/types.js +4 -0
- package/dist/commonjs/types.js.map +1 -0
- package/dist/commonjs/utils.d.ts +55 -0
- package/dist/commonjs/utils.d.ts.map +1 -0
- package/dist/commonjs/utils.js +91 -0
- package/dist/commonjs/utils.js.map +1 -0
- package/dist/esm/api/attributes.d.ts +385 -0
- package/dist/esm/api/attributes.d.ts.map +1 -0
- package/dist/esm/api/attributes.js +636 -0
- package/dist/esm/api/attributes.js.map +1 -0
- package/dist/esm/api/css.d.ts +42 -0
- package/dist/esm/api/css.d.ts.map +1 -0
- package/dist/esm/api/css.js +116 -0
- package/dist/esm/api/css.js.map +1 -0
- package/dist/esm/api/extract.d.ts +27 -0
- package/dist/esm/api/extract.d.ts.map +1 -0
- package/dist/esm/api/extract.js +42 -0
- package/dist/esm/api/extract.js.map +1 -0
- package/dist/esm/api/forms.d.ts +36 -0
- package/dist/esm/api/forms.d.ts.map +1 -0
- package/dist/esm/api/forms.js +81 -0
- package/dist/esm/api/forms.js.map +1 -0
- package/dist/esm/api/manipulation.d.ts +528 -0
- package/dist/esm/api/manipulation.d.ts.map +1 -0
- package/dist/esm/api/manipulation.js +831 -0
- package/dist/esm/api/manipulation.js.map +1 -0
- package/dist/esm/api/traversing.d.ts +657 -0
- package/dist/esm/api/traversing.d.ts.map +1 -0
- package/dist/esm/api/traversing.js +857 -0
- package/dist/esm/api/traversing.js.map +1 -0
- package/dist/esm/cheerio.d.ts +85 -0
- package/dist/esm/cheerio.d.ts.map +1 -0
- package/dist/esm/cheerio.js +58 -0
- package/dist/esm/cheerio.js.map +1 -0
- package/dist/esm/index.d.ts +104 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +202 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/load-parse.d.ts +20 -0
- package/dist/esm/load-parse.d.ts.map +1 -0
- package/dist/esm/load-parse.js +28 -0
- package/dist/esm/load-parse.js.map +1 -0
- package/dist/esm/load.d.ts +91 -0
- package/dist/esm/load.d.ts.map +1 -0
- package/dist/esm/load.js +129 -0
- package/dist/esm/load.js.map +1 -0
- package/dist/esm/options.d.ts +98 -0
- package/dist/esm/options.d.ts.map +1 -0
- package/dist/esm/options.js +34 -0
- package/dist/esm/options.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/parse.d.ts +18 -0
- package/dist/esm/parse.d.ts.map +1 -0
- package/dist/esm/parse.js +73 -0
- package/dist/esm/parse.js.map +1 -0
- package/dist/esm/parsers/parse5-adapter.d.ts +20 -0
- package/dist/esm/parsers/parse5-adapter.d.ts.map +1 -0
- package/dist/esm/parsers/parse5-adapter.js +50 -0
- package/dist/esm/parsers/parse5-adapter.js.map +1 -0
- package/dist/esm/slim.d.ts +25 -0
- package/dist/esm/slim.d.ts.map +1 -0
- package/dist/esm/slim.js +22 -0
- package/dist/esm/slim.js.map +1 -0
- package/dist/esm/static.d.ts +112 -0
- package/dist/esm/static.d.ts.map +1 -0
- package/dist/esm/static.js +204 -0
- package/dist/esm/static.js.map +1 -0
- package/dist/esm/types.d.ts +21 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +3 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils.d.ts +55 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/utils.js +84 -0
- package/dist/esm/utils.js.map +1 -0
- package/package.json +219 -0
- package/src/api/attributes.ts +1145 -0
- package/src/api/css.ts +224 -0
- package/src/api/extract.ts +92 -0
- package/src/api/forms.ts +103 -0
- package/src/api/manipulation.ts +1115 -0
- package/src/api/traversing.ts +1175 -0
- package/src/cheerio.ts +143 -0
- package/src/index-browser.mts +10 -0
- package/src/index.ts +294 -0
- package/src/load-parse.ts +39 -0
- package/src/load.ts +282 -0
- package/src/options.ts +136 -0
- package/src/parse.ts +105 -0
- package/src/parsers/parse5-adapter.ts +66 -0
- package/src/slim.ts +33 -0
- package/src/static.ts +312 -0
- package/src/types.ts +58 -0
- package/src/utils.ts +99 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type AnyNode, Document, type ParentNode } from 'domhandler';
|
|
2
|
+
import type { InternalOptions } from './options.js';
|
|
3
|
+
/**
|
|
4
|
+
* Get the parse function with options.
|
|
5
|
+
*
|
|
6
|
+
* @param parser - The parser function.
|
|
7
|
+
* @returns The parse function with options.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getParse(parser: (content: string, options: InternalOptions, isDocument: boolean, context: ParentNode | null) => Document): (content: string | Document | AnyNode | AnyNode[] | Buffer, options: InternalOptions, isDocument: boolean, context: ParentNode | null) => Document;
|
|
10
|
+
/**
|
|
11
|
+
* Update the dom structure, for one changed layer.
|
|
12
|
+
*
|
|
13
|
+
* @param newChilds - The new children.
|
|
14
|
+
* @param parent - The new parent.
|
|
15
|
+
* @returns The parent node.
|
|
16
|
+
*/
|
|
17
|
+
export declare function update(newChilds: AnyNode[] | AnyNode, parent: ParentNode | null): ParentNode | null;
|
|
18
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/parse.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,OAAO,EACZ,QAAQ,EACR,KAAK,UAAU,EAEhB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,CACN,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,UAAU,GAAG,IAAI,KACvB,QAAQ,IAYX,SAAS,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,EAAE,GAAG,MAAM,EACzD,SAAS,eAAe,EACxB,YAAY,OAAO,EACnB,SAAS,UAAU,GAAG,IAAI,KACzB,QAAQ,CAwBZ;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,EAC9B,MAAM,EAAE,UAAU,GAAG,IAAI,GACxB,UAAU,GAAG,IAAI,CA+BnB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { removeElement } from 'domutils';
|
|
2
|
+
import { Document, isDocument as checkIsDocument, } from 'domhandler';
|
|
3
|
+
/**
|
|
4
|
+
* Get the parse function with options.
|
|
5
|
+
*
|
|
6
|
+
* @param parser - The parser function.
|
|
7
|
+
* @returns The parse function with options.
|
|
8
|
+
*/
|
|
9
|
+
export function getParse(parser) {
|
|
10
|
+
/**
|
|
11
|
+
* Parse a HTML string or a node.
|
|
12
|
+
*
|
|
13
|
+
* @param content - The HTML string or node.
|
|
14
|
+
* @param options - The parser options.
|
|
15
|
+
* @param isDocument - If `content` is a document.
|
|
16
|
+
* @param context - The context node in the DOM tree.
|
|
17
|
+
* @returns The parsed document node.
|
|
18
|
+
*/
|
|
19
|
+
return function parse(content, options, isDocument, context) {
|
|
20
|
+
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(content)) {
|
|
21
|
+
content = content.toString();
|
|
22
|
+
}
|
|
23
|
+
if (typeof content === 'string') {
|
|
24
|
+
return parser(content, options, isDocument, context);
|
|
25
|
+
}
|
|
26
|
+
const doc = content;
|
|
27
|
+
if (!Array.isArray(doc) && checkIsDocument(doc)) {
|
|
28
|
+
// If `doc` is already a root, just return it
|
|
29
|
+
return doc;
|
|
30
|
+
}
|
|
31
|
+
// Add content to new root element
|
|
32
|
+
const root = new Document([]);
|
|
33
|
+
// Update the DOM using the root
|
|
34
|
+
update(doc, root);
|
|
35
|
+
return root;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Update the dom structure, for one changed layer.
|
|
40
|
+
*
|
|
41
|
+
* @param newChilds - The new children.
|
|
42
|
+
* @param parent - The new parent.
|
|
43
|
+
* @returns The parent node.
|
|
44
|
+
*/
|
|
45
|
+
export function update(newChilds, parent) {
|
|
46
|
+
// Normalize
|
|
47
|
+
const arr = Array.isArray(newChilds) ? newChilds : [newChilds];
|
|
48
|
+
// Update parent
|
|
49
|
+
if (parent) {
|
|
50
|
+
parent.children = arr;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
parent = null;
|
|
54
|
+
}
|
|
55
|
+
// Update neighbors
|
|
56
|
+
for (let i = 0; i < arr.length; i++) {
|
|
57
|
+
const node = arr[i];
|
|
58
|
+
// Cleanly remove existing nodes from their previous structures.
|
|
59
|
+
if (node.parent && node.parent.children !== arr) {
|
|
60
|
+
removeElement(node);
|
|
61
|
+
}
|
|
62
|
+
if (parent) {
|
|
63
|
+
node.prev = arr[i - 1] || null;
|
|
64
|
+
node.next = arr[i + 1] || null;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
node.prev = node.next = null;
|
|
68
|
+
}
|
|
69
|
+
node.parent = parent;
|
|
70
|
+
}
|
|
71
|
+
return parent;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAEL,QAAQ,EAER,UAAU,IAAI,eAAe,GAC9B,MAAM,YAAY,CAAC;AAGpB;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CACtB,MAKa;IAEb;;;;;;;;OAQG;IACH,OAAO,SAAS,KAAK,CACnB,OAA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AAC,CAAC;QAEpB,gEAAgE;QAChE,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,GAAG,EAAE,CAAC;YAChD,aAAa,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;QAED,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC;YAC/B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAC/B,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type AnyNode, type Document, type ParentNode } from 'domhandler';
|
|
2
|
+
import type { InternalOptions } from '../options.js';
|
|
3
|
+
/**
|
|
4
|
+
* Parse the content with `parse5` in the context of the given `ParentNode`.
|
|
5
|
+
*
|
|
6
|
+
* @param content - The content to parse.
|
|
7
|
+
* @param options - A set of options to use to parse.
|
|
8
|
+
* @param isDocument - Whether to parse the content as a full HTML document.
|
|
9
|
+
* @param context - The context in which to parse the content.
|
|
10
|
+
* @returns The parsed content.
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseWithParse5(content: string, options: InternalOptions, isDocument: boolean, context: ParentNode | null): Document;
|
|
13
|
+
/**
|
|
14
|
+
* Renders the given DOM tree with `parse5` and returns the result as a string.
|
|
15
|
+
*
|
|
16
|
+
* @param dom - The DOM tree to render.
|
|
17
|
+
* @returns The rendered document.
|
|
18
|
+
*/
|
|
19
|
+
export declare function renderWithParse5(dom: AnyNode | ArrayLike<AnyNode>): string;
|
|
20
|
+
//# sourceMappingURL=parse5-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse5-adapter.d.ts","sourceRoot":"","sources":["../../../src/parsers/parse5-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,UAAU,EAEhB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,UAAU,GAAG,IAAI,GACzB,QAAQ,CAUV;AAID;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,MAAM,CAqB1E"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isDocument, } from 'domhandler';
|
|
2
|
+
import { parse as parseDocument, parseFragment, serializeOuter } from 'parse5';
|
|
3
|
+
import { adapter as htmlparser2Adapter } from 'parse5-htmlparser2-tree-adapter';
|
|
4
|
+
/**
|
|
5
|
+
* Parse the content with `parse5` in the context of the given `ParentNode`.
|
|
6
|
+
*
|
|
7
|
+
* @param content - The content to parse.
|
|
8
|
+
* @param options - A set of options to use to parse.
|
|
9
|
+
* @param isDocument - Whether to parse the content as a full HTML document.
|
|
10
|
+
* @param context - The context in which to parse the content.
|
|
11
|
+
* @returns The parsed content.
|
|
12
|
+
*/
|
|
13
|
+
export function parseWithParse5(content, options, isDocument, context) {
|
|
14
|
+
var _a;
|
|
15
|
+
(_a = options.treeAdapter) !== null && _a !== void 0 ? _a : (options.treeAdapter = htmlparser2Adapter);
|
|
16
|
+
if (options.scriptingEnabled !== false) {
|
|
17
|
+
options.scriptingEnabled = true;
|
|
18
|
+
}
|
|
19
|
+
return isDocument
|
|
20
|
+
? parseDocument(content, options)
|
|
21
|
+
: parseFragment(context, content, options);
|
|
22
|
+
}
|
|
23
|
+
const renderOpts = { treeAdapter: htmlparser2Adapter };
|
|
24
|
+
/**
|
|
25
|
+
* Renders the given DOM tree with `parse5` and returns the result as a string.
|
|
26
|
+
*
|
|
27
|
+
* @param dom - The DOM tree to render.
|
|
28
|
+
* @returns The rendered document.
|
|
29
|
+
*/
|
|
30
|
+
export function renderWithParse5(dom) {
|
|
31
|
+
/*
|
|
32
|
+
* `dom-serializer` passes over the special "root" node and renders the
|
|
33
|
+
* node's children in its place. To mimic this behavior with `parse5`, an
|
|
34
|
+
* equivalent operation must be applied to the input array.
|
|
35
|
+
*/
|
|
36
|
+
const nodes = 'length' in dom ? dom : [dom];
|
|
37
|
+
for (let index = 0; index < nodes.length; index += 1) {
|
|
38
|
+
const node = nodes[index];
|
|
39
|
+
if (isDocument(node)) {
|
|
40
|
+
Array.prototype.splice.call(nodes, index, 1, ...node.children);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
let result = '';
|
|
44
|
+
for (let index = 0; index < nodes.length; index += 1) {
|
|
45
|
+
const node = nodes[index];
|
|
46
|
+
result += serializeOuter(node, renderOpts);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=parse5-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse5-adapter.js","sourceRoot":"","sources":["../../../src/parsers/parse5-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAGhF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAe,EACf,OAAwB,EACxB,UAAmB,EACnB,OAA0B;;IAE1B,MAAA,OAAO,CAAC,WA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}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Alternative entry point for Cheerio that always uses htmlparser2. This
|
|
3
|
+
* way, parse5 won't be loaded, saving some memory.
|
|
4
|
+
*/
|
|
5
|
+
import { type CheerioAPI } from './load.js';
|
|
6
|
+
import { type CheerioOptions } from './options.js';
|
|
7
|
+
import type { AnyNode } from 'domhandler';
|
|
8
|
+
export { contains, merge } from './static.js';
|
|
9
|
+
export type * from './types.js';
|
|
10
|
+
export type { Cheerio } from './cheerio.js';
|
|
11
|
+
export type { CheerioOptions, HTMLParser2Options } from './options.js';
|
|
12
|
+
export type { CheerioAPI } from './load.js';
|
|
13
|
+
/**
|
|
14
|
+
* Create a querying function, bound to a document created from the provided
|
|
15
|
+
* markup.
|
|
16
|
+
*
|
|
17
|
+
* @param content - Markup to be loaded.
|
|
18
|
+
* @param options - Options for the created instance.
|
|
19
|
+
* @param isDocument - Always `false` here, as we are always using
|
|
20
|
+
* `htmlparser2`.
|
|
21
|
+
* @returns The loaded document.
|
|
22
|
+
* @see {@link https://cheerio.js.org#loading} for additional usage information.
|
|
23
|
+
*/
|
|
24
|
+
export declare const load: (content: string | AnyNode | AnyNode[] | Buffer, options?: CheerioOptions | null, isDocument?: boolean) => CheerioAPI;
|
|
25
|
+
//# sourceMappingURL=slim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slim.d.ts","sourceRoot":"","sources":["../../src/slim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,UAAU,EAAW,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC9C,mBAAmB,YAAY,CAAC;AAChC,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,EAAE,CACjB,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,EAAE,GAAG,MAAM,EAC9C,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,EAC/B,UAAU,CAAC,EAAE,OAAO,KACjB,UAAqD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Alternative entry point for Cheerio that always uses htmlparser2. This
|
|
3
|
+
* way, parse5 won't be loaded, saving some memory.
|
|
4
|
+
*/
|
|
5
|
+
import { getLoad } from './load.js';
|
|
6
|
+
import { getParse } from './parse.js';
|
|
7
|
+
import render from 'dom-serializer';
|
|
8
|
+
import { parseDocument } from 'htmlparser2';
|
|
9
|
+
export { contains, merge } from './static.js';
|
|
10
|
+
/**
|
|
11
|
+
* Create a querying function, bound to a document created from the provided
|
|
12
|
+
* markup.
|
|
13
|
+
*
|
|
14
|
+
* @param content - Markup to be loaded.
|
|
15
|
+
* @param options - Options for the created instance.
|
|
16
|
+
* @param isDocument - Always `false` here, as we are always using
|
|
17
|
+
* `htmlparser2`.
|
|
18
|
+
* @returns The loaded document.
|
|
19
|
+
* @see {@link https://cheerio.js.org#loading} for additional usage information.
|
|
20
|
+
*/
|
|
21
|
+
export const load = getLoad(getParse(parseDocument), render);
|
|
22
|
+
//# sourceMappingURL=slim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slim.js","sourceRoot":"","sources":["../../src/slim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAmB,OAAO,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAM9C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,IAAI,GAIC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { BasicAcceptedElems } from './types.js';
|
|
2
|
+
import type { CheerioAPI } from './load.js';
|
|
3
|
+
import type { Cheerio } from './cheerio.js';
|
|
4
|
+
import type { AnyNode, Document } from 'domhandler';
|
|
5
|
+
import { type CheerioOptions } from './options.js';
|
|
6
|
+
import type { ExtractedMap, ExtractMap } from './api/extract.js';
|
|
7
|
+
/**
|
|
8
|
+
* Renders the document.
|
|
9
|
+
*
|
|
10
|
+
* @category Static
|
|
11
|
+
* @param options - Options for the renderer.
|
|
12
|
+
* @returns The rendered document.
|
|
13
|
+
*/
|
|
14
|
+
export declare function html(this: CheerioAPI, options?: CheerioOptions): string;
|
|
15
|
+
/**
|
|
16
|
+
* Renders the document.
|
|
17
|
+
*
|
|
18
|
+
* @category Static
|
|
19
|
+
* @param dom - Element to render.
|
|
20
|
+
* @param options - Options for the renderer.
|
|
21
|
+
* @returns The rendered document.
|
|
22
|
+
*/
|
|
23
|
+
export declare function html(this: CheerioAPI, dom?: BasicAcceptedElems<AnyNode>, options?: CheerioOptions): string;
|
|
24
|
+
/**
|
|
25
|
+
* Render the document as XML.
|
|
26
|
+
*
|
|
27
|
+
* @category Static
|
|
28
|
+
* @param dom - Element to render.
|
|
29
|
+
* @returns THe rendered document.
|
|
30
|
+
*/
|
|
31
|
+
export declare function xml(this: CheerioAPI, dom?: BasicAcceptedElems<AnyNode>): string;
|
|
32
|
+
/**
|
|
33
|
+
* Render the document as text.
|
|
34
|
+
*
|
|
35
|
+
* This returns the `textContent` of the passed elements. The result will
|
|
36
|
+
* include the contents of `<script>` and `<style>` elements. To avoid this, use
|
|
37
|
+
* `.prop('innerText')` instead.
|
|
38
|
+
*
|
|
39
|
+
* @category Static
|
|
40
|
+
* @param elements - Elements to render.
|
|
41
|
+
* @returns The rendered document.
|
|
42
|
+
*/
|
|
43
|
+
export declare function text(this: CheerioAPI | void, elements?: ArrayLike<AnyNode>): string;
|
|
44
|
+
/**
|
|
45
|
+
* Parses a string into an array of DOM nodes. The `context` argument has no
|
|
46
|
+
* meaning for Cheerio, but it is maintained for API compatibility with jQuery.
|
|
47
|
+
*
|
|
48
|
+
* @category Static
|
|
49
|
+
* @param data - Markup that will be parsed.
|
|
50
|
+
* @param context - Will be ignored. If it is a boolean it will be used as the
|
|
51
|
+
* value of `keepScripts`.
|
|
52
|
+
* @param keepScripts - If false all scripts will be removed.
|
|
53
|
+
* @returns The parsed DOM.
|
|
54
|
+
* @alias Cheerio.parseHTML
|
|
55
|
+
* @see {@link https://api.jquery.com/jQuery.parseHTML/}
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseHTML(this: CheerioAPI, data: string, context?: unknown, keepScripts?: boolean): AnyNode[];
|
|
58
|
+
export declare function parseHTML(this: CheerioAPI, data?: '' | null): null;
|
|
59
|
+
/**
|
|
60
|
+
* Sometimes you need to work with the top-level root element. To query it, you
|
|
61
|
+
* can use `$.root()`.
|
|
62
|
+
*
|
|
63
|
+
* @category Static
|
|
64
|
+
* @example
|
|
65
|
+
*
|
|
66
|
+
* ```js
|
|
67
|
+
* $.root().append('<ul id="vegetables"></ul>').html();
|
|
68
|
+
* //=> <ul id="fruits">...</ul><ul id="vegetables"></ul>
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @returns Cheerio instance wrapping the root node.
|
|
72
|
+
* @alias Cheerio.root
|
|
73
|
+
*/
|
|
74
|
+
export declare function root(this: CheerioAPI): Cheerio<Document>;
|
|
75
|
+
/**
|
|
76
|
+
* Checks to see if the `contained` DOM element is a descendant of the
|
|
77
|
+
* `container` DOM element.
|
|
78
|
+
*
|
|
79
|
+
* @category Static
|
|
80
|
+
* @param container - Potential parent node.
|
|
81
|
+
* @param contained - Potential child node.
|
|
82
|
+
* @returns Indicates if the nodes contain one another.
|
|
83
|
+
* @alias Cheerio.contains
|
|
84
|
+
* @see {@link https://api.jquery.com/jQuery.contains/}
|
|
85
|
+
*/
|
|
86
|
+
export declare function contains(container: AnyNode, contained: AnyNode): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Extract multiple values from a document, and store them in an object.
|
|
89
|
+
*
|
|
90
|
+
* @category Static
|
|
91
|
+
* @param map - An object containing key-value pairs. The keys are the names of
|
|
92
|
+
* the properties to be created on the object, and the values are the
|
|
93
|
+
* selectors to be used to extract the values.
|
|
94
|
+
* @returns An object containing the extracted values.
|
|
95
|
+
*/
|
|
96
|
+
export declare function extract<M extends ExtractMap>(this: CheerioAPI, map: M): ExtractedMap<M>;
|
|
97
|
+
type Writable<T> = {
|
|
98
|
+
-readonly [P in keyof T]: T[P];
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* $.merge().
|
|
102
|
+
*
|
|
103
|
+
* @category Static
|
|
104
|
+
* @param arr1 - First array.
|
|
105
|
+
* @param arr2 - Second array.
|
|
106
|
+
* @returns `arr1`, with elements of `arr2` inserted.
|
|
107
|
+
* @alias Cheerio.merge
|
|
108
|
+
* @see {@link https://api.jquery.com/jQuery.merge/}
|
|
109
|
+
*/
|
|
110
|
+
export declare function merge<T>(arr1: Writable<ArrayLike<T>>, arr2: ArrayLike<T>): ArrayLike<T> | undefined;
|
|
111
|
+
export {};
|
|
112
|
+
//# sourceMappingURL=static.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../src/static.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA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C,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAmBxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,UAAU,EAC1C,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,CAAC,GACL,YAAY,CAAC,CAAC,CAAC,CAEjB;AAED,KAAK,QAAQ,CAAC,CAAC,IAAI;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAEtD;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,CAAC,EACrB,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAC5B,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,GACjB,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAY1B"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { textContent } from 'domutils';
|
|
2
|
+
import { flattenOptions as flattenOptions, } from './options.js';
|
|
3
|
+
/**
|
|
4
|
+
* Helper function to render a DOM.
|
|
5
|
+
*
|
|
6
|
+
* @param that - Cheerio instance to render.
|
|
7
|
+
* @param dom - The DOM to render. Defaults to `that`'s root.
|
|
8
|
+
* @param options - Options for rendering.
|
|
9
|
+
* @returns The rendered document.
|
|
10
|
+
*/
|
|
11
|
+
function render(that, dom, options) {
|
|
12
|
+
if (!that)
|
|
13
|
+
return '';
|
|
14
|
+
return that(dom !== null && dom !== void 0 ? dom : that._root.children, null, undefined, options).toString();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Checks if a passed object is an options object.
|
|
18
|
+
*
|
|
19
|
+
* @param dom - Object to check if it is an options object.
|
|
20
|
+
* @param options - Options object.
|
|
21
|
+
* @returns Whether the object is an options object.
|
|
22
|
+
*/
|
|
23
|
+
function isOptions(dom, options) {
|
|
24
|
+
return (!options &&
|
|
25
|
+
typeof dom === 'object' &&
|
|
26
|
+
dom != null &&
|
|
27
|
+
!('length' in dom) &&
|
|
28
|
+
!('type' in dom));
|
|
29
|
+
}
|
|
30
|
+
export function html(dom, options) {
|
|
31
|
+
/*
|
|
32
|
+
* Be flexible about parameters, sometimes we call html(),
|
|
33
|
+
* with options as only parameter
|
|
34
|
+
* check dom argument for dom element specific properties
|
|
35
|
+
* assume there is no 'length' or 'type' properties in the options object
|
|
36
|
+
*/
|
|
37
|
+
const toRender = isOptions(dom) ? ((options = dom), undefined) : dom;
|
|
38
|
+
/*
|
|
39
|
+
* Sometimes `$.html()` is used without preloading html,
|
|
40
|
+
* so fallback non-existing options to the default ones.
|
|
41
|
+
*/
|
|
42
|
+
const opts = {
|
|
43
|
+
...this === null || this === void 0 ? void 0 : this._options,
|
|
44
|
+
...flattenOptions(options),
|
|
45
|
+
};
|
|
46
|
+
return render(this, toRender, opts);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Render the document as XML.
|
|
50
|
+
*
|
|
51
|
+
* @category Static
|
|
52
|
+
* @param dom - Element to render.
|
|
53
|
+
* @returns THe rendered document.
|
|
54
|
+
*/
|
|
55
|
+
export function xml(dom) {
|
|
56
|
+
const options = { ...this._options, xmlMode: true };
|
|
57
|
+
return render(this, dom, options);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Render the document as text.
|
|
61
|
+
*
|
|
62
|
+
* This returns the `textContent` of the passed elements. The result will
|
|
63
|
+
* include the contents of `<script>` and `<style>` elements. To avoid this, use
|
|
64
|
+
* `.prop('innerText')` instead.
|
|
65
|
+
*
|
|
66
|
+
* @category Static
|
|
67
|
+
* @param elements - Elements to render.
|
|
68
|
+
* @returns The rendered document.
|
|
69
|
+
*/
|
|
70
|
+
export function text(elements) {
|
|
71
|
+
const elems = elements !== null && elements !== void 0 ? elements : (this ? this.root() : []);
|
|
72
|
+
let ret = '';
|
|
73
|
+
for (let i = 0; i < elems.length; i++) {
|
|
74
|
+
ret += textContent(elems[i]);
|
|
75
|
+
}
|
|
76
|
+
return ret;
|
|
77
|
+
}
|
|
78
|
+
export function parseHTML(data, context, keepScripts = typeof context === 'boolean' ? context : false) {
|
|
79
|
+
if (!data || typeof data !== 'string') {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
if (typeof context === 'boolean') {
|
|
83
|
+
keepScripts = context;
|
|
84
|
+
}
|
|
85
|
+
const parsed = this.load(data, this._options, false);
|
|
86
|
+
if (!keepScripts) {
|
|
87
|
+
parsed('script').remove();
|
|
88
|
+
}
|
|
89
|
+
/*
|
|
90
|
+
* The `children` array is used by Cheerio internally to group elements that
|
|
91
|
+
* share the same parents. When nodes created through `parseHTML` are
|
|
92
|
+
* inserted into previously-existing DOM structures, they will be removed
|
|
93
|
+
* from the `children` array. The results of `parseHTML` should remain
|
|
94
|
+
* constant across these operations, so a shallow copy should be returned.
|
|
95
|
+
*/
|
|
96
|
+
return [...parsed.root()[0].children];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Sometimes you need to work with the top-level root element. To query it, you
|
|
100
|
+
* can use `$.root()`.
|
|
101
|
+
*
|
|
102
|
+
* @category Static
|
|
103
|
+
* @example
|
|
104
|
+
*
|
|
105
|
+
* ```js
|
|
106
|
+
* $.root().append('<ul id="vegetables"></ul>').html();
|
|
107
|
+
* //=> <ul id="fruits">...</ul><ul id="vegetables"></ul>
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @returns Cheerio instance wrapping the root node.
|
|
111
|
+
* @alias Cheerio.root
|
|
112
|
+
*/
|
|
113
|
+
export function root() {
|
|
114
|
+
return this(this._root);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Checks to see if the `contained` DOM element is a descendant of the
|
|
118
|
+
* `container` DOM element.
|
|
119
|
+
*
|
|
120
|
+
* @category Static
|
|
121
|
+
* @param container - Potential parent node.
|
|
122
|
+
* @param contained - Potential child node.
|
|
123
|
+
* @returns Indicates if the nodes contain one another.
|
|
124
|
+
* @alias Cheerio.contains
|
|
125
|
+
* @see {@link https://api.jquery.com/jQuery.contains/}
|
|
126
|
+
*/
|
|
127
|
+
export function contains(container, contained) {
|
|
128
|
+
// According to the jQuery API, an element does not "contain" itself
|
|
129
|
+
if (contained === container) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
/*
|
|
133
|
+
* Step up the descendants, stopping when the root element is reached
|
|
134
|
+
* (signaled by `.parent` returning a reference to the same object)
|
|
135
|
+
*/
|
|
136
|
+
let next = contained;
|
|
137
|
+
while (next && next !== next.parent) {
|
|
138
|
+
next = next.parent;
|
|
139
|
+
if (next === container) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Extract multiple values from a document, and store them in an object.
|
|
147
|
+
*
|
|
148
|
+
* @category Static
|
|
149
|
+
* @param map - An object containing key-value pairs. The keys are the names of
|
|
150
|
+
* the properties to be created on the object, and the values are the
|
|
151
|
+
* selectors to be used to extract the values.
|
|
152
|
+
* @returns An object containing the extracted values.
|
|
153
|
+
*/
|
|
154
|
+
export function extract(map) {
|
|
155
|
+
return this.root().extract(map);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* $.merge().
|
|
159
|
+
*
|
|
160
|
+
* @category Static
|
|
161
|
+
* @param arr1 - First array.
|
|
162
|
+
* @param arr2 - Second array.
|
|
163
|
+
* @returns `arr1`, with elements of `arr2` inserted.
|
|
164
|
+
* @alias Cheerio.merge
|
|
165
|
+
* @see {@link https://api.jquery.com/jQuery.merge/}
|
|
166
|
+
*/
|
|
167
|
+
export function merge(arr1, arr2) {
|
|
168
|
+
if (!isArrayLike(arr1) || !isArrayLike(arr2)) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
let newLength = arr1.length;
|
|
172
|
+
const len = +arr2.length;
|
|
173
|
+
for (let i = 0; i < len; i++) {
|
|
174
|
+
arr1[newLength++] = arr2[i];
|
|
175
|
+
}
|
|
176
|
+
arr1.length = newLength;
|
|
177
|
+
return arr1;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Checks if an object is array-like.
|
|
181
|
+
*
|
|
182
|
+
* @category Static
|
|
183
|
+
* @param item - Item to check.
|
|
184
|
+
* @returns Indicates if the item is array-like.
|
|
185
|
+
*/
|
|
186
|
+
function isArrayLike(item) {
|
|
187
|
+
if (Array.isArray(item)) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
if (typeof item !== 'object' ||
|
|
191
|
+
item === null ||
|
|
192
|
+
!('length' in item) ||
|
|
193
|
+
typeof item.length !== 'number' ||
|
|
194
|
+
item.length < 0) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
for (let i = 0; i < item.length; i++) {
|
|
198
|
+
if (!(i in item)) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=static.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static.js","sourceRoot":"","sources":["../../src/static.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAGL,cAAc,IAAI,cAAc,GACjC,MAAM,cAAc,CAAC;AAGtB;;;;;;;GAOG;AACH,SAAS,MAAM,CACb,IAAgB,EAChB,GAA4C,EAC5C,OAAwB;IAExB,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IAErB,OAAO,IAAI,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC/E,CAAC;AAED;;;;;;GAMG;AACH,SAAS,SAAS,CAChB,GAAyD,EACzD,OAAwB;IAExB,OAAO,CACL,CAAC,OAAO;QACR,OAA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AAI,CAAC,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** @file Types used in signatures of Cheerio methods. */
|
|
2
|
+
type LowercaseLetters = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
|
|
3
|
+
type AlphaNumeric = LowercaseLetters | Uppercase<LowercaseLetters> | `${number}`;
|
|
4
|
+
type SelectorSpecial = '.' | '#' | ':' | '|' | '>' | '+' | '~' | '[';
|
|
5
|
+
/**
|
|
6
|
+
* Type for identifying selectors. Allows us to "upgrade" queries using
|
|
7
|
+
* selectors to return `Element`s.
|
|
8
|
+
*/
|
|
9
|
+
export type SelectorType = `${SelectorSpecial}${AlphaNumeric}${string}` | `${AlphaNumeric}${string}`;
|
|
10
|
+
import type { Cheerio } from './cheerio.js';
|
|
11
|
+
import type { AnyNode } from 'domhandler';
|
|
12
|
+
/** Elements that can be passed to manipulation methods. */
|
|
13
|
+
export type BasicAcceptedElems<T extends AnyNode> = ArrayLike<T> | T | string;
|
|
14
|
+
/** Elements that can be passed to manipulation methods, including functions. */
|
|
15
|
+
export type AcceptedElems<T extends AnyNode> = BasicAcceptedElems<T> | ((this: T, i: number, el: T) => BasicAcceptedElems<T>);
|
|
16
|
+
/** Function signature, for traversal methods. */
|
|
17
|
+
export type FilterFunction<T> = (this: T, i: number, el: T) => boolean;
|
|
18
|
+
/** Supported filter types, for traversal methods. */
|
|
19
|
+
export type AcceptedFilters<T> = string | FilterFunction<T> | T | Cheerio<T>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"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,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC;AACvE,qDAAqD;AACrD,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,yDAAyD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AnyNode } from 'domhandler';
|
|
2
|
+
import type { Cheerio } from './cheerio.js';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if an object is a Cheerio instance.
|
|
5
|
+
*
|
|
6
|
+
* @category Utils
|
|
7
|
+
* @param maybeCheerio - The object to check.
|
|
8
|
+
* @returns Whether the object is a Cheerio instance.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isCheerio<T>(maybeCheerio: unknown): maybeCheerio is Cheerio<T>;
|
|
11
|
+
/**
|
|
12
|
+
* Convert a string to camel case notation.
|
|
13
|
+
*
|
|
14
|
+
* @private
|
|
15
|
+
* @category Utils
|
|
16
|
+
* @param str - The string to be converted.
|
|
17
|
+
* @returns String in camel case notation.
|
|
18
|
+
*/
|
|
19
|
+
export declare function camelCase(str: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Convert a string from camel case to "CSS case", where word boundaries are
|
|
22
|
+
* described by hyphens ("-") and all characters are lower-case.
|
|
23
|
+
*
|
|
24
|
+
* @private
|
|
25
|
+
* @category Utils
|
|
26
|
+
* @param str - The string to be converted.
|
|
27
|
+
* @returns String in "CSS case".
|
|
28
|
+
*/
|
|
29
|
+
export declare function cssCase(str: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Iterate over each DOM element without creating intermediary Cheerio
|
|
32
|
+
* instances.
|
|
33
|
+
*
|
|
34
|
+
* This is indented for use internally to avoid otherwise unnecessary memory
|
|
35
|
+
* pressure introduced by _make.
|
|
36
|
+
*
|
|
37
|
+
* @category Utils
|
|
38
|
+
* @param array - The array to iterate over.
|
|
39
|
+
* @param fn - Function to call.
|
|
40
|
+
* @returns The original instance.
|
|
41
|
+
*/
|
|
42
|
+
export declare function domEach<T extends AnyNode, Arr extends ArrayLike<T> = Cheerio<T>>(array: Arr, fn: (elem: T, index: number) => void): Arr;
|
|
43
|
+
/**
|
|
44
|
+
* Check if string is HTML.
|
|
45
|
+
*
|
|
46
|
+
* Tests for a `<` within a string, immediate followed by a letter and
|
|
47
|
+
* eventually followed by a `>`.
|
|
48
|
+
*
|
|
49
|
+
* @private
|
|
50
|
+
* @category Utils
|
|
51
|
+
* @param str - The string to check.
|
|
52
|
+
* @returns Indicates if `str` is HTML.
|
|
53
|
+
*/
|
|
54
|
+
export declare function isHtml(str: string): boolean;
|
|
55
|
+
//# sourceMappingURL=utils.d.ts.map
|