@umijs/utils 3.5.18 → 4.0.0-beta.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/README.md +2 -0
- package/compiled/address/index.js +1 -0
- package/compiled/address/lib/address.d.ts +28 -0
- package/compiled/address/package.json +1 -0
- package/compiled/axios/LICENSE +19 -0
- package/compiled/axios/index.d.ts +206 -0
- package/compiled/axios/index.js +1 -0
- package/compiled/axios/package.json +1 -0
- package/compiled/chalk/LICENSE +9 -0
- package/compiled/chalk/index.d.ts +415 -0
- package/compiled/chalk/index.js +1 -0
- package/compiled/chalk/package.json +1 -0
- package/compiled/cheerio/LICENSE +21 -0
- package/compiled/cheerio/domelementtype/lib/index.d.ts +48 -0
- package/compiled/cheerio/domhandler/lib/index.d.ts +85 -0
- package/compiled/cheerio/domhandler/lib/node.d.ts +169 -0
- package/compiled/cheerio/htmlparser2/lib/Parser.d.ts +159 -0
- package/compiled/cheerio/htmlparser2/lib/Tokenizer.d.ts +182 -0
- package/compiled/cheerio/htmlparser2/lib/index.d.ts +39 -0
- package/compiled/cheerio/index.js +16 -0
- package/compiled/cheerio/lib/api/attributes.d.ts +317 -0
- package/compiled/cheerio/lib/api/css.d.ts +41 -0
- package/compiled/cheerio/lib/api/forms.d.ts +31 -0
- package/compiled/cheerio/lib/api/manipulation.d.ts +496 -0
- package/compiled/cheerio/lib/api/traversing.d.ts +644 -0
- package/compiled/cheerio/lib/cheerio.d.ts +53 -0
- package/compiled/cheerio/lib/index.d.ts +91 -0
- package/compiled/cheerio/lib/load.d.ts +73 -0
- package/compiled/cheerio/lib/options.d.ts +31 -0
- package/compiled/cheerio/lib/static.d.ts +88 -0
- package/compiled/cheerio/lib/types.d.ts +20 -0
- package/compiled/cheerio/package.json +1 -0
- package/compiled/color/LICENSE +21 -0
- package/compiled/color/color-convert/conversions.d.ts +149 -0
- package/compiled/color/color-convert/index.d.ts +113 -0
- package/compiled/color/color-convert/route.d.ts +294 -0
- package/compiled/color/color-name/index.d.ts +161 -0
- package/compiled/color/index.d.ts +142 -0
- package/compiled/color/index.js +1 -0
- package/compiled/color/package.json +4 -0
- package/compiled/cross-spawn/LICENSE +21 -0
- package/compiled/cross-spawn/index.d.ts +36 -0
- package/compiled/cross-spawn/index.js +1 -0
- package/compiled/cross-spawn/package.json +1 -0
- package/compiled/debug/LICENSE +19 -0
- package/compiled/debug/index.d.ts +54 -0
- package/compiled/debug/index.js +1 -0
- package/compiled/debug/ms/index.d.ts +25 -0
- package/compiled/debug/package.json +1 -0
- package/compiled/deepmerge/index.d.ts +16 -0
- package/compiled/deepmerge/index.js +1 -0
- package/compiled/deepmerge/package.json +1 -0
- package/compiled/execa/LICENSE +9 -0
- package/compiled/execa/index.d.ts +564 -0
- package/compiled/execa/index.js +1 -0
- package/compiled/execa/package.json +1 -0
- package/compiled/fs-extra/LICENSE +15 -0
- package/compiled/fs-extra/index.d.ts +332 -0
- package/compiled/fs-extra/index.js +1 -0
- package/compiled/fs-extra/package.json +1 -0
- package/compiled/glob/LICENSE +21 -0
- package/compiled/glob/index.d.ts +89 -0
- package/compiled/glob/index.js +1 -0
- package/compiled/glob/minimatch/index.d.ts +204 -0
- package/compiled/glob/package.json +1 -0
- package/compiled/import-lazy/LICENSE +9 -0
- package/compiled/import-lazy/index.d.ts +26 -0
- package/compiled/import-lazy/index.js +1 -0
- package/compiled/import-lazy/package.json +1 -0
- package/compiled/lodash/LICENSE +47 -0
- package/compiled/lodash/common/array.d.ts +2126 -0
- package/compiled/lodash/common/collection.d.ts +1930 -0
- package/compiled/lodash/common/common.d.ts +280 -0
- package/compiled/lodash/common/date.d.ts +23 -0
- package/compiled/lodash/common/function.d.ts +1430 -0
- package/compiled/lodash/common/lang.d.ts +1692 -0
- package/compiled/lodash/common/math.d.ts +405 -0
- package/compiled/lodash/common/number.d.ts +131 -0
- package/compiled/lodash/common/object.d.ts +2519 -0
- package/compiled/lodash/common/seq.d.ts +210 -0
- package/compiled/lodash/common/string.d.ts +788 -0
- package/compiled/lodash/common/util.d.ts +1219 -0
- package/compiled/lodash/index.d.ts +46 -0
- package/compiled/lodash/index.js +9 -0
- package/compiled/lodash/package.json +1 -0
- package/compiled/mustache/LICENSE +11 -0
- package/compiled/mustache/index.d.ts +437 -0
- package/compiled/mustache/index.js +5 -0
- package/compiled/mustache/package.json +1 -0
- package/compiled/pkg-up/LICENSE +9 -0
- package/compiled/pkg-up/index.d.ts +48 -0
- package/compiled/pkg-up/index.js +1 -0
- package/compiled/pkg-up/package.json +1 -0
- package/compiled/portfinder/LICENSE +22 -0
- package/compiled/portfinder/index.js +1 -0
- package/compiled/portfinder/lib/portfinder.d.ts +47 -0
- package/compiled/portfinder/package.json +1 -0
- package/compiled/prettier/LICENSE +7 -0
- package/compiled/prettier/index.d.ts +867 -0
- package/compiled/prettier/index.js +475 -0
- package/compiled/prettier/package.json +5 -0
- package/compiled/prompts/LICENSE +21 -0
- package/compiled/prompts/index.d.ts +120 -0
- package/compiled/prompts/index.js +1 -0
- package/compiled/prompts/package.json +1 -0
- package/compiled/resolve/LICENSE +21 -0
- package/compiled/resolve/index.d.ts +166 -0
- package/compiled/resolve/index.js +1 -0
- package/compiled/resolve/package.json +1 -0
- package/compiled/rimraf/LICENSE +15 -0
- package/compiled/rimraf/glob/index.d.ts +89 -0
- package/compiled/rimraf/index.d.ts +49 -0
- package/compiled/rimraf/index.js +1 -0
- package/compiled/rimraf/minimatch/index.d.ts +204 -0
- package/compiled/rimraf/package.json +1 -0
- package/compiled/semver/LICENSE +15 -0
- package/compiled/semver/classes/comparator.d.ts +17 -0
- package/compiled/semver/classes/range.d.ts +21 -0
- package/compiled/semver/classes/semver.d.ts +62 -0
- package/compiled/semver/functions/clean.d.ts +8 -0
- package/compiled/semver/functions/cmp.d.ts +16 -0
- package/compiled/semver/functions/coerce.d.ts +12 -0
- package/compiled/semver/functions/compare-build.d.ts +16 -0
- package/compiled/semver/functions/compare-loose.d.ts +5 -0
- package/compiled/semver/functions/compare.d.ts +20 -0
- package/compiled/semver/functions/diff.d.ts +13 -0
- package/compiled/semver/functions/eq.d.ts +9 -0
- package/compiled/semver/functions/gt.d.ts +9 -0
- package/compiled/semver/functions/gte.d.ts +9 -0
- package/compiled/semver/functions/inc.d.ts +15 -0
- package/compiled/semver/functions/lt.d.ts +9 -0
- package/compiled/semver/functions/lte.d.ts +8 -0
- package/compiled/semver/functions/major.d.ts +9 -0
- package/compiled/semver/functions/minor.d.ts +9 -0
- package/compiled/semver/functions/neq.d.ts +9 -0
- package/compiled/semver/functions/parse.d.ts +12 -0
- package/compiled/semver/functions/patch.d.ts +9 -0
- package/compiled/semver/functions/prerelease.d.ts +12 -0
- package/compiled/semver/functions/rcompare.d.ts +15 -0
- package/compiled/semver/functions/rsort.d.ts +9 -0
- package/compiled/semver/functions/satisfies.d.ts +14 -0
- package/compiled/semver/functions/sort.d.ts +9 -0
- package/compiled/semver/functions/valid.d.ts +11 -0
- package/compiled/semver/index.d.ts +133 -0
- package/compiled/semver/index.js +1 -0
- package/compiled/semver/internals/identifiers.d.ts +13 -0
- package/compiled/semver/package.json +1 -0
- package/compiled/semver/ranges/gtr.d.ts +14 -0
- package/compiled/semver/ranges/intersects.d.ts +13 -0
- package/compiled/semver/ranges/ltr.d.ts +14 -0
- package/compiled/semver/ranges/max-satisfying.d.ts +14 -0
- package/compiled/semver/ranges/min-satisfying.d.ts +14 -0
- package/compiled/semver/ranges/min-version.d.ts +10 -0
- package/compiled/semver/ranges/outside.d.ts +15 -0
- package/compiled/semver/ranges/simplify.d.ts +14 -0
- package/compiled/semver/ranges/subset.d.ts +13 -0
- package/compiled/semver/ranges/to-comparators.d.ts +9 -0
- package/compiled/semver/ranges/valid.d.ts +12 -0
- package/compiled/strip-ansi/LICENSE +9 -0
- package/compiled/strip-ansi/index.d.ts +17 -0
- package/compiled/strip-ansi/index.js +1 -0
- package/compiled/strip-ansi/package.json +1 -0
- package/compiled/yargs-parser/index.d.ts +112 -0
- package/compiled/yargs-parser/index.js +1 -0
- package/compiled/yargs-parser/package.json +1 -0
- package/dist/BaseGenerator/BaseGenerator.d.ts +18 -0
- package/dist/BaseGenerator/BaseGenerator.js +58 -0
- package/dist/BaseGenerator/generateFile.d.ts +8 -0
- package/dist/BaseGenerator/generateFile.js +25 -0
- package/{lib → dist}/Generator/Generator.d.ts +3 -3
- package/dist/Generator/Generator.js +74 -0
- package/dist/importLazy.d.ts +6 -0
- package/dist/importLazy.js +17 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +88 -0
- package/dist/installDeps.d.ts +9 -0
- package/dist/installDeps.js +39 -0
- package/dist/logger.d.ts +14 -0
- package/dist/logger.js +39 -0
- package/dist/npmClient.d.ts +15 -0
- package/dist/npmClient.js +43 -0
- package/dist/randomColor/randomColor.d.ts +6 -0
- package/dist/randomColor/randomColor.js +19 -0
- package/dist/register.d.ts +6 -0
- package/dist/register.js +47 -0
- package/dist/updatePackageJSON.d.ts +5 -0
- package/dist/updatePackageJSON.js +21 -0
- package/dist/winPath.d.ts +1 -0
- package/dist/winPath.js +11 -0
- package/package.json +96 -12
- package/lib/BabelRegister/BabelRegister.d.ts +0 -9
- package/lib/BabelRegister/BabelRegister.js +0 -66
- package/lib/Generator/Generator.js +0 -120
- package/lib/cheerio/cheerio.d.ts +0 -2
- package/lib/cheerio/cheerio.js +0 -37
- package/lib/cleanRequireCache/cleanRequireCache.d.ts +0 -1
- package/lib/cleanRequireCache/cleanRequireCache.js +0 -40
- package/lib/compatESModuleRequire/compatESModuleRequire.d.ts +0 -7
- package/lib/compatESModuleRequire/compatESModuleRequire.js +0 -22
- package/lib/delay/delay.d.ts +0 -1
- package/lib/delay/delay.js +0 -22
- package/lib/getFile/getFile.d.ts +0 -22
- package/lib/getFile/getFile.js +0 -85
- package/lib/index.d.ts +0 -66
- package/lib/index.js +0 -619
- package/lib/isLernaPackage/isLernaPackage.d.ts +0 -1
- package/lib/isLernaPackage/isLernaPackage.js +0 -42
- package/lib/mergeConfig/mergeConfig.d.ts +0 -8
- package/lib/mergeConfig/mergeConfig.js +0 -42
- package/lib/parseRequireDeps/parseRequireDeps.d.ts +0 -1
- package/lib/parseRequireDeps/parseRequireDeps.js +0 -98
- package/lib/randomColor/randomColor.d.ts +0 -6
- package/lib/randomColor/randomColor.js +0 -42
- package/lib/routes.d.ts +0 -11
- package/lib/routes.js +0 -53
- package/lib/ssr.d.ts +0 -12
- package/lib/ssr.js +0 -41
- package/lib/types.d.ts +0 -7
- package/lib/types.js +0 -17
- package/lib/winEOL/winEOL.d.ts +0 -7
- package/lib/winEOL/winEOL.js +0 -39
- package/lib/winPath/winPath.d.ts +0 -1
- package/lib/winPath/winPath.js +0 -28
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Methods for modifying the DOM structure.
|
|
3
|
+
*
|
|
4
|
+
* @module cheerio/manipulation
|
|
5
|
+
*/
|
|
6
|
+
import { Node } from '../../domhandler';
|
|
7
|
+
import type { Cheerio } from '../cheerio';
|
|
8
|
+
import type { BasicAcceptedElems, AcceptedElems } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Create an array of nodes, recursing into arrays and parsing strings if necessary.
|
|
11
|
+
*
|
|
12
|
+
* @private
|
|
13
|
+
* @category Manipulation
|
|
14
|
+
* @param elem - Elements to make an array of.
|
|
15
|
+
* @param clone - Optionally clone nodes.
|
|
16
|
+
* @returns The array of nodes.
|
|
17
|
+
*/
|
|
18
|
+
export declare function _makeDomArray<T extends Node>(this: Cheerio<T>, elem?: BasicAcceptedElems<Node>, clone?: boolean): Node[];
|
|
19
|
+
/**
|
|
20
|
+
* Insert every element in the set of matched elements to the end of the target.
|
|
21
|
+
*
|
|
22
|
+
* @category Manipulation
|
|
23
|
+
* @example
|
|
24
|
+
*
|
|
25
|
+
* ```js
|
|
26
|
+
* $('<li class="plum">Plum</li>').appendTo('#fruits');
|
|
27
|
+
* $.html();
|
|
28
|
+
* //=> <ul id="fruits">
|
|
29
|
+
* // <li class="apple">Apple</li>
|
|
30
|
+
* // <li class="orange">Orange</li>
|
|
31
|
+
* // <li class="pear">Pear</li>
|
|
32
|
+
* // <li class="plum">Plum</li>
|
|
33
|
+
* // </ul>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param target - Element to append elements to.
|
|
37
|
+
* @returns The instance itself.
|
|
38
|
+
* @see {@link https://api.jquery.com/appendTo/}
|
|
39
|
+
*/
|
|
40
|
+
export declare function appendTo<T extends Node>(this: Cheerio<T>, target: BasicAcceptedElems<Node>): Cheerio<T>;
|
|
41
|
+
/**
|
|
42
|
+
* Insert every element in the set of matched elements to the beginning of the target.
|
|
43
|
+
*
|
|
44
|
+
* @category Manipulation
|
|
45
|
+
* @example
|
|
46
|
+
*
|
|
47
|
+
* ```js
|
|
48
|
+
* $('<li class="plum">Plum</li>').prependTo('#fruits');
|
|
49
|
+
* $.html();
|
|
50
|
+
* //=> <ul id="fruits">
|
|
51
|
+
* // <li class="plum">Plum</li>
|
|
52
|
+
* // <li class="apple">Apple</li>
|
|
53
|
+
* // <li class="orange">Orange</li>
|
|
54
|
+
* // <li class="pear">Pear</li>
|
|
55
|
+
* // </ul>
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param target - Element to prepend elements to.
|
|
59
|
+
* @returns The instance itself.
|
|
60
|
+
* @see {@link https://api.jquery.com/prependTo/}
|
|
61
|
+
*/
|
|
62
|
+
export declare function prependTo<T extends Node>(this: Cheerio<T>, target: BasicAcceptedElems<Node>): Cheerio<T>;
|
|
63
|
+
/**
|
|
64
|
+
* Inserts content as the *last* child of each of the selected elements.
|
|
65
|
+
*
|
|
66
|
+
* @category Manipulation
|
|
67
|
+
* @example
|
|
68
|
+
*
|
|
69
|
+
* ```js
|
|
70
|
+
* $('ul').append('<li class="plum">Plum</li>');
|
|
71
|
+
* $.html();
|
|
72
|
+
* //=> <ul id="fruits">
|
|
73
|
+
* // <li class="apple">Apple</li>
|
|
74
|
+
* // <li class="orange">Orange</li>
|
|
75
|
+
* // <li class="pear">Pear</li>
|
|
76
|
+
* // <li class="plum">Plum</li>
|
|
77
|
+
* // </ul>
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @see {@link https://api.jquery.com/append/}
|
|
81
|
+
*/
|
|
82
|
+
export declare const append: <T extends Node>(this: Cheerio<T>, ...elems: [(this: Node, i: number, html: string) => BasicAcceptedElems<Node>] | BasicAcceptedElems<Node>[]) => Cheerio<T>;
|
|
83
|
+
/**
|
|
84
|
+
* Inserts content as the *first* child of each of the selected elements.
|
|
85
|
+
*
|
|
86
|
+
* @category Manipulation
|
|
87
|
+
* @example
|
|
88
|
+
*
|
|
89
|
+
* ```js
|
|
90
|
+
* $('ul').prepend('<li class="plum">Plum</li>');
|
|
91
|
+
* $.html();
|
|
92
|
+
* //=> <ul id="fruits">
|
|
93
|
+
* // <li class="plum">Plum</li>
|
|
94
|
+
* // <li class="apple">Apple</li>
|
|
95
|
+
* // <li class="orange">Orange</li>
|
|
96
|
+
* // <li class="pear">Pear</li>
|
|
97
|
+
* // </ul>
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @see {@link https://api.jquery.com/prepend/}
|
|
101
|
+
*/
|
|
102
|
+
export declare const prepend: <T extends Node>(this: Cheerio<T>, ...elems: [(this: Node, i: number, html: string) => BasicAcceptedElems<Node>] | BasicAcceptedElems<Node>[]) => Cheerio<T>;
|
|
103
|
+
/**
|
|
104
|
+
* The .wrap() function can take any string or object that could be passed to
|
|
105
|
+
* the $() factory function to specify a DOM structure. This structure may be
|
|
106
|
+
* nested several levels deep, but should contain only one inmost element. A
|
|
107
|
+
* copy of this structure will be wrapped around each of the elements in the set
|
|
108
|
+
* of matched elements. This method returns the original set of elements for
|
|
109
|
+
* chaining purposes.
|
|
110
|
+
*
|
|
111
|
+
* @category Manipulation
|
|
112
|
+
* @example
|
|
113
|
+
*
|
|
114
|
+
* ```js
|
|
115
|
+
* const redFruit = $('<div class="red-fruit"></div>');
|
|
116
|
+
* $('.apple').wrap(redFruit);
|
|
117
|
+
*
|
|
118
|
+
* //=> <ul id="fruits">
|
|
119
|
+
* // <div class="red-fruit">
|
|
120
|
+
* // <li class="apple">Apple</li>
|
|
121
|
+
* // </div>
|
|
122
|
+
* // <li class="orange">Orange</li>
|
|
123
|
+
* // <li class="plum">Plum</li>
|
|
124
|
+
* // </ul>
|
|
125
|
+
*
|
|
126
|
+
* const healthy = $('<div class="healthy"></div>');
|
|
127
|
+
* $('li').wrap(healthy);
|
|
128
|
+
*
|
|
129
|
+
* //=> <ul id="fruits">
|
|
130
|
+
* // <div class="healthy">
|
|
131
|
+
* // <li class="apple">Apple</li>
|
|
132
|
+
* // </div>
|
|
133
|
+
* // <div class="healthy">
|
|
134
|
+
* // <li class="orange">Orange</li>
|
|
135
|
+
* // </div>
|
|
136
|
+
* // <div class="healthy">
|
|
137
|
+
* // <li class="plum">Plum</li>
|
|
138
|
+
* // </div>
|
|
139
|
+
* // </ul>
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @param wrapper - The DOM structure to wrap around each element in the selection.
|
|
143
|
+
* @see {@link https://api.jquery.com/wrap/}
|
|
144
|
+
*/
|
|
145
|
+
export declare const wrap: <T extends Node>(this: Cheerio<T>, wrapper: AcceptedElems<Node>) => Cheerio<T>;
|
|
146
|
+
/**
|
|
147
|
+
* The .wrapInner() function can take any string or object that could be passed
|
|
148
|
+
* to the $() factory function to specify a DOM structure. This structure may be
|
|
149
|
+
* nested several levels deep, but should contain only one inmost element. The
|
|
150
|
+
* structure will be wrapped around the content of each of the elements in the
|
|
151
|
+
* set of matched elements.
|
|
152
|
+
*
|
|
153
|
+
* @category Manipulation
|
|
154
|
+
* @example
|
|
155
|
+
*
|
|
156
|
+
* ```js
|
|
157
|
+
* const redFruit = $('<div class="red-fruit"></div>');
|
|
158
|
+
* $('.apple').wrapInner(redFruit);
|
|
159
|
+
*
|
|
160
|
+
* //=> <ul id="fruits">
|
|
161
|
+
* // <li class="apple">
|
|
162
|
+
* // <div class="red-fruit">Apple</div>
|
|
163
|
+
* // </li>
|
|
164
|
+
* // <li class="orange">Orange</li>
|
|
165
|
+
* // <li class="pear">Pear</li>
|
|
166
|
+
* // </ul>
|
|
167
|
+
*
|
|
168
|
+
* const healthy = $('<div class="healthy"></div>');
|
|
169
|
+
* $('li').wrapInner(healthy);
|
|
170
|
+
*
|
|
171
|
+
* //=> <ul id="fruits">
|
|
172
|
+
* // <li class="apple">
|
|
173
|
+
* // <div class="healthy">Apple</div>
|
|
174
|
+
* // </li>
|
|
175
|
+
* // <li class="orange">
|
|
176
|
+
* // <div class="healthy">Orange</div>
|
|
177
|
+
* // </li>
|
|
178
|
+
* // <li class="pear">
|
|
179
|
+
* // <div class="healthy">Pear</div>
|
|
180
|
+
* // </li>
|
|
181
|
+
* // </ul>
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* @param wrapper - The DOM structure to wrap around the content of each element
|
|
185
|
+
* in the selection.
|
|
186
|
+
* @returns The instance itself, for chaining.
|
|
187
|
+
* @see {@link https://api.jquery.com/wrapInner/}
|
|
188
|
+
*/
|
|
189
|
+
export declare const wrapInner: <T extends Node>(this: Cheerio<T>, wrapper: AcceptedElems<Node>) => Cheerio<T>;
|
|
190
|
+
/**
|
|
191
|
+
* The .unwrap() function, removes the parents of the set of matched elements
|
|
192
|
+
* from the DOM, leaving the matched elements in their place.
|
|
193
|
+
*
|
|
194
|
+
* @category Manipulation
|
|
195
|
+
* @example <caption>without selector</caption>
|
|
196
|
+
*
|
|
197
|
+
* ```js
|
|
198
|
+
* const $ = cheerio.load(
|
|
199
|
+
* '<div id=test>\n <div><p>Hello</p></div>\n <div><p>World</p></div>\n</div>'
|
|
200
|
+
* );
|
|
201
|
+
* $('#test p').unwrap();
|
|
202
|
+
*
|
|
203
|
+
* //=> <div id=test>
|
|
204
|
+
* // <p>Hello</p>
|
|
205
|
+
* // <p>World</p>
|
|
206
|
+
* // </div>
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* @example <caption>with selector</caption>
|
|
210
|
+
*
|
|
211
|
+
* ```js
|
|
212
|
+
* const $ = cheerio.load(
|
|
213
|
+
* '<div id=test>\n <p>Hello</p>\n <b><p>World</p></b>\n</div>'
|
|
214
|
+
* );
|
|
215
|
+
* $('#test p').unwrap('b');
|
|
216
|
+
*
|
|
217
|
+
* //=> <div id=test>
|
|
218
|
+
* // <p>Hello</p>
|
|
219
|
+
* // <p>World</p>
|
|
220
|
+
* // </div>
|
|
221
|
+
* ```
|
|
222
|
+
*
|
|
223
|
+
* @param selector - A selector to check the parent element against. If an
|
|
224
|
+
* element's parent does not match the selector, the element won't be unwrapped.
|
|
225
|
+
* @returns The instance itself, for chaining.
|
|
226
|
+
* @see {@link https://api.jquery.com/unwrap/}
|
|
227
|
+
*/
|
|
228
|
+
export declare function unwrap<T extends Node>(this: Cheerio<T>, selector?: string): Cheerio<T>;
|
|
229
|
+
/**
|
|
230
|
+
* The .wrapAll() function can take any string or object that could be passed to
|
|
231
|
+
* the $() function to specify a DOM structure. This structure may be nested
|
|
232
|
+
* several levels deep, but should contain only one inmost element. The
|
|
233
|
+
* structure will be wrapped around all of the elements in the set of matched
|
|
234
|
+
* elements, as a single group.
|
|
235
|
+
*
|
|
236
|
+
* @category Manipulation
|
|
237
|
+
* @example <caption>With markup passed to `wrapAll`</caption>
|
|
238
|
+
*
|
|
239
|
+
* ```js
|
|
240
|
+
* const $ = cheerio.load(
|
|
241
|
+
* '<div class="container"><div class="inner">First</div><div class="inner">Second</div></div>'
|
|
242
|
+
* );
|
|
243
|
+
* $('.inner').wrapAll("<div class='new'></div>");
|
|
244
|
+
*
|
|
245
|
+
* //=> <div class="container">
|
|
246
|
+
* // <div class='new'>
|
|
247
|
+
* // <div class="inner">First</div>
|
|
248
|
+
* // <div class="inner">Second</div>
|
|
249
|
+
* // </div>
|
|
250
|
+
* // </div>
|
|
251
|
+
* ```
|
|
252
|
+
*
|
|
253
|
+
* @example <caption>With an existing cheerio instance</caption>
|
|
254
|
+
*
|
|
255
|
+
* ```js
|
|
256
|
+
* const $ = cheerio.load(
|
|
257
|
+
* '<span>Span 1</span><strong>Strong</strong><span>Span 2</span>'
|
|
258
|
+
* );
|
|
259
|
+
* const wrap = $('<div><p><em><b></b></em></p></div>');
|
|
260
|
+
* $('span').wrapAll(wrap);
|
|
261
|
+
*
|
|
262
|
+
* //=> <div>
|
|
263
|
+
* // <p>
|
|
264
|
+
* // <em>
|
|
265
|
+
* // <b>
|
|
266
|
+
* // <span>Span 1</span>
|
|
267
|
+
* // <span>Span 2</span>
|
|
268
|
+
* // </b>
|
|
269
|
+
* // </em>
|
|
270
|
+
* // </p>
|
|
271
|
+
* // </div>
|
|
272
|
+
* // <strong>Strong</strong>
|
|
273
|
+
* ```
|
|
274
|
+
*
|
|
275
|
+
* @param wrapper - The DOM structure to wrap around all matched elements in the
|
|
276
|
+
* selection.
|
|
277
|
+
* @returns The instance itself.
|
|
278
|
+
* @see {@link https://api.jquery.com/wrapAll/}
|
|
279
|
+
*/
|
|
280
|
+
export declare function wrapAll<T extends Node>(this: Cheerio<T>, wrapper: AcceptedElems<T>): Cheerio<T>;
|
|
281
|
+
/**
|
|
282
|
+
* Insert content next to each element in the set of matched elements.
|
|
283
|
+
*
|
|
284
|
+
* @category Manipulation
|
|
285
|
+
* @example
|
|
286
|
+
*
|
|
287
|
+
* ```js
|
|
288
|
+
* $('.apple').after('<li class="plum">Plum</li>');
|
|
289
|
+
* $.html();
|
|
290
|
+
* //=> <ul id="fruits">
|
|
291
|
+
* // <li class="apple">Apple</li>
|
|
292
|
+
* // <li class="plum">Plum</li>
|
|
293
|
+
* // <li class="orange">Orange</li>
|
|
294
|
+
* // <li class="pear">Pear</li>
|
|
295
|
+
* // </ul>
|
|
296
|
+
* ```
|
|
297
|
+
*
|
|
298
|
+
* @param content - HTML string, DOM element, array of DOM elements or Cheerio
|
|
299
|
+
* to insert after each element in the set of matched elements.
|
|
300
|
+
* @returns The instance itself.
|
|
301
|
+
* @see {@link https://api.jquery.com/after/}
|
|
302
|
+
*/
|
|
303
|
+
export declare function after<T extends Node>(this: Cheerio<T>, ...elems: [(this: Node, i: number, html: string) => BasicAcceptedElems<Node>] | BasicAcceptedElems<Node>[]): Cheerio<T>;
|
|
304
|
+
/**
|
|
305
|
+
* Insert every element in the set of matched elements after the target.
|
|
306
|
+
*
|
|
307
|
+
* @category Manipulation
|
|
308
|
+
* @example
|
|
309
|
+
*
|
|
310
|
+
* ```js
|
|
311
|
+
* $('<li class="plum">Plum</li>').insertAfter('.apple');
|
|
312
|
+
* $.html();
|
|
313
|
+
* //=> <ul id="fruits">
|
|
314
|
+
* // <li class="apple">Apple</li>
|
|
315
|
+
* // <li class="plum">Plum</li>
|
|
316
|
+
* // <li class="orange">Orange</li>
|
|
317
|
+
* // <li class="pear">Pear</li>
|
|
318
|
+
* // </ul>
|
|
319
|
+
* ```
|
|
320
|
+
*
|
|
321
|
+
* @param target - Element to insert elements after.
|
|
322
|
+
* @returns The set of newly inserted elements.
|
|
323
|
+
* @see {@link https://api.jquery.com/insertAfter/}
|
|
324
|
+
*/
|
|
325
|
+
export declare function insertAfter<T extends Node>(this: Cheerio<T>, target: BasicAcceptedElems<Node>): Cheerio<T>;
|
|
326
|
+
/**
|
|
327
|
+
* Insert content previous to each element in the set of matched elements.
|
|
328
|
+
*
|
|
329
|
+
* @category Manipulation
|
|
330
|
+
* @example
|
|
331
|
+
*
|
|
332
|
+
* ```js
|
|
333
|
+
* $('.apple').before('<li class="plum">Plum</li>');
|
|
334
|
+
* $.html();
|
|
335
|
+
* //=> <ul id="fruits">
|
|
336
|
+
* // <li class="plum">Plum</li>
|
|
337
|
+
* // <li class="apple">Apple</li>
|
|
338
|
+
* // <li class="orange">Orange</li>
|
|
339
|
+
* // <li class="pear">Pear</li>
|
|
340
|
+
* // </ul>
|
|
341
|
+
* ```
|
|
342
|
+
*
|
|
343
|
+
* @param content - HTML string, DOM element, array of DOM elements or Cheerio
|
|
344
|
+
* to insert before each element in the set of matched elements.
|
|
345
|
+
* @returns The instance itself.
|
|
346
|
+
* @see {@link https://api.jquery.com/before/}
|
|
347
|
+
*/
|
|
348
|
+
export declare function before<T extends Node>(this: Cheerio<T>, ...elems: [(this: Node, i: number, html: string) => BasicAcceptedElems<Node>] | BasicAcceptedElems<Node>[]): Cheerio<T>;
|
|
349
|
+
/**
|
|
350
|
+
* Insert every element in the set of matched elements before the target.
|
|
351
|
+
*
|
|
352
|
+
* @category Manipulation
|
|
353
|
+
* @example
|
|
354
|
+
*
|
|
355
|
+
* ```js
|
|
356
|
+
* $('<li class="plum">Plum</li>').insertBefore('.apple');
|
|
357
|
+
* $.html();
|
|
358
|
+
* //=> <ul id="fruits">
|
|
359
|
+
* // <li class="plum">Plum</li>
|
|
360
|
+
* // <li class="apple">Apple</li>
|
|
361
|
+
* // <li class="orange">Orange</li>
|
|
362
|
+
* // <li class="pear">Pear</li>
|
|
363
|
+
* // </ul>
|
|
364
|
+
* ```
|
|
365
|
+
*
|
|
366
|
+
* @param target - Element to insert elements before.
|
|
367
|
+
* @returns The set of newly inserted elements.
|
|
368
|
+
* @see {@link https://api.jquery.com/insertBefore/}
|
|
369
|
+
*/
|
|
370
|
+
export declare function insertBefore<T extends Node>(this: Cheerio<T>, target: BasicAcceptedElems<Node>): Cheerio<T>;
|
|
371
|
+
/**
|
|
372
|
+
* Removes the set of matched elements from the DOM and all their children.
|
|
373
|
+
* `selector` filters the set of matched elements to be removed.
|
|
374
|
+
*
|
|
375
|
+
* @category Manipulation
|
|
376
|
+
* @example
|
|
377
|
+
*
|
|
378
|
+
* ```js
|
|
379
|
+
* $('.pear').remove();
|
|
380
|
+
* $.html();
|
|
381
|
+
* //=> <ul id="fruits">
|
|
382
|
+
* // <li class="apple">Apple</li>
|
|
383
|
+
* // <li class="orange">Orange</li>
|
|
384
|
+
* // </ul>
|
|
385
|
+
* ```
|
|
386
|
+
*
|
|
387
|
+
* @param selector - Optional selector for elements to remove.
|
|
388
|
+
* @returns The instance itself.
|
|
389
|
+
* @see {@link https://api.jquery.com/remove/}
|
|
390
|
+
*/
|
|
391
|
+
export declare function remove<T extends Node>(this: Cheerio<T>, selector?: string): Cheerio<T>;
|
|
392
|
+
/**
|
|
393
|
+
* Replaces matched elements with `content`.
|
|
394
|
+
*
|
|
395
|
+
* @category Manipulation
|
|
396
|
+
* @example
|
|
397
|
+
*
|
|
398
|
+
* ```js
|
|
399
|
+
* const plum = $('<li class="plum">Plum</li>');
|
|
400
|
+
* $('.pear').replaceWith(plum);
|
|
401
|
+
* $.html();
|
|
402
|
+
* //=> <ul id="fruits">
|
|
403
|
+
* // <li class="apple">Apple</li>
|
|
404
|
+
* // <li class="orange">Orange</li>
|
|
405
|
+
* // <li class="plum">Plum</li>
|
|
406
|
+
* // </ul>
|
|
407
|
+
* ```
|
|
408
|
+
*
|
|
409
|
+
* @param content - Replacement for matched elements.
|
|
410
|
+
* @returns The instance itself.
|
|
411
|
+
* @see {@link https://api.jquery.com/replaceWith/}
|
|
412
|
+
*/
|
|
413
|
+
export declare function replaceWith<T extends Node>(this: Cheerio<T>, content: AcceptedElems<Node>): Cheerio<T>;
|
|
414
|
+
/**
|
|
415
|
+
* Empties an element, removing all its children.
|
|
416
|
+
*
|
|
417
|
+
* @category Manipulation
|
|
418
|
+
* @example
|
|
419
|
+
*
|
|
420
|
+
* ```js
|
|
421
|
+
* $('ul').empty();
|
|
422
|
+
* $.html();
|
|
423
|
+
* //=> <ul id="fruits"></ul>
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
* @returns The instance itself.
|
|
427
|
+
* @see {@link https://api.jquery.com/empty/}
|
|
428
|
+
*/
|
|
429
|
+
export declare function empty<T extends Node>(this: Cheerio<T>): Cheerio<T>;
|
|
430
|
+
/**
|
|
431
|
+
* Gets an HTML content string from the first selected element. If `htmlString`
|
|
432
|
+
* is specified, each selected element's content is replaced by the new content.
|
|
433
|
+
*
|
|
434
|
+
* @category Manipulation
|
|
435
|
+
* @example
|
|
436
|
+
*
|
|
437
|
+
* ```js
|
|
438
|
+
* $('.orange').html();
|
|
439
|
+
* //=> Orange
|
|
440
|
+
*
|
|
441
|
+
* $('#fruits').html('<li class="mango">Mango</li>').html();
|
|
442
|
+
* //=> <li class="mango">Mango</li>
|
|
443
|
+
* ```
|
|
444
|
+
*
|
|
445
|
+
* @param str - If specified used to replace selection's contents.
|
|
446
|
+
* @returns The instance itself.
|
|
447
|
+
* @see {@link https://api.jquery.com/html/}
|
|
448
|
+
*/
|
|
449
|
+
export declare function html<T extends Node>(this: Cheerio<T>): string | null;
|
|
450
|
+
export declare function html<T extends Node>(this: Cheerio<T>, str: string | Cheerio<T>): Cheerio<T>;
|
|
451
|
+
/**
|
|
452
|
+
* Turns the collection to a string. Alias for `.html()`.
|
|
453
|
+
*
|
|
454
|
+
* @category Manipulation
|
|
455
|
+
* @returns The rendered document.
|
|
456
|
+
*/
|
|
457
|
+
export declare function toString<T extends Node>(this: Cheerio<T>): string;
|
|
458
|
+
/**
|
|
459
|
+
* Get the combined text contents of each element in the set of matched
|
|
460
|
+
* elements, including their descendants. If `textString` is specified, each
|
|
461
|
+
* selected element's content is replaced by the new text content.
|
|
462
|
+
*
|
|
463
|
+
* @category Manipulation
|
|
464
|
+
* @example
|
|
465
|
+
*
|
|
466
|
+
* ```js
|
|
467
|
+
* $('.orange').text();
|
|
468
|
+
* //=> Orange
|
|
469
|
+
*
|
|
470
|
+
* $('ul').text();
|
|
471
|
+
* //=> Apple
|
|
472
|
+
* // Orange
|
|
473
|
+
* // Pear
|
|
474
|
+
* ```
|
|
475
|
+
*
|
|
476
|
+
* @param str - If specified replacement for the selected element's contents.
|
|
477
|
+
* @returns The instance itself when setting text, otherwise the rendered document.
|
|
478
|
+
* @see {@link https://api.jquery.com/text/}
|
|
479
|
+
*/
|
|
480
|
+
export declare function text<T extends Node>(this: Cheerio<T>): string;
|
|
481
|
+
export declare function text<T extends Node>(this: Cheerio<T>, str: string | ((this: Node, i: number, text: string) => string)): Cheerio<T>;
|
|
482
|
+
/**
|
|
483
|
+
* Clone the cheerio object.
|
|
484
|
+
*
|
|
485
|
+
* @category Manipulation
|
|
486
|
+
* @example
|
|
487
|
+
*
|
|
488
|
+
* ```js
|
|
489
|
+
* const moreFruit = $('#fruits').clone();
|
|
490
|
+
* ```
|
|
491
|
+
*
|
|
492
|
+
* @returns The cloned object.
|
|
493
|
+
* @see {@link https://api.jquery.com/clone/}
|
|
494
|
+
*/
|
|
495
|
+
export declare function clone<T extends Node>(this: Cheerio<T>): Cheerio<T>;
|
|
496
|
+
//# sourceMappingURL=manipulation.d.ts.map
|