@umijs/utils 3.5.19 → 4.0.0-beta.11

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.
Files changed (223) hide show
  1. package/README.md +2 -0
  2. package/compiled/address/index.js +1 -0
  3. package/compiled/address/lib/address.d.ts +28 -0
  4. package/compiled/address/package.json +1 -0
  5. package/compiled/axios/LICENSE +19 -0
  6. package/compiled/axios/index.d.ts +206 -0
  7. package/compiled/axios/index.js +1 -0
  8. package/compiled/axios/package.json +1 -0
  9. package/compiled/chalk/LICENSE +9 -0
  10. package/compiled/chalk/index.d.ts +415 -0
  11. package/compiled/chalk/index.js +1 -0
  12. package/compiled/chalk/package.json +1 -0
  13. package/compiled/cheerio/LICENSE +21 -0
  14. package/compiled/cheerio/domelementtype/lib/index.d.ts +48 -0
  15. package/compiled/cheerio/domhandler/lib/index.d.ts +85 -0
  16. package/compiled/cheerio/domhandler/lib/node.d.ts +169 -0
  17. package/compiled/cheerio/htmlparser2/lib/Parser.d.ts +159 -0
  18. package/compiled/cheerio/htmlparser2/lib/Tokenizer.d.ts +182 -0
  19. package/compiled/cheerio/htmlparser2/lib/index.d.ts +39 -0
  20. package/compiled/cheerio/index.js +16 -0
  21. package/compiled/cheerio/lib/api/attributes.d.ts +317 -0
  22. package/compiled/cheerio/lib/api/css.d.ts +41 -0
  23. package/compiled/cheerio/lib/api/forms.d.ts +31 -0
  24. package/compiled/cheerio/lib/api/manipulation.d.ts +496 -0
  25. package/compiled/cheerio/lib/api/traversing.d.ts +644 -0
  26. package/compiled/cheerio/lib/cheerio.d.ts +53 -0
  27. package/compiled/cheerio/lib/index.d.ts +91 -0
  28. package/compiled/cheerio/lib/load.d.ts +73 -0
  29. package/compiled/cheerio/lib/options.d.ts +31 -0
  30. package/compiled/cheerio/lib/static.d.ts +88 -0
  31. package/compiled/cheerio/lib/types.d.ts +20 -0
  32. package/compiled/cheerio/package.json +1 -0
  33. package/compiled/color/LICENSE +21 -0
  34. package/compiled/color/color-convert/conversions.d.ts +149 -0
  35. package/compiled/color/color-convert/index.d.ts +113 -0
  36. package/compiled/color/color-convert/route.d.ts +294 -0
  37. package/compiled/color/color-name/index.d.ts +161 -0
  38. package/compiled/color/index.d.ts +142 -0
  39. package/compiled/color/index.js +1 -0
  40. package/compiled/color/package.json +4 -0
  41. package/compiled/cross-spawn/LICENSE +21 -0
  42. package/compiled/cross-spawn/index.d.ts +36 -0
  43. package/compiled/cross-spawn/index.js +1 -0
  44. package/compiled/cross-spawn/package.json +1 -0
  45. package/compiled/debug/LICENSE +19 -0
  46. package/compiled/debug/index.d.ts +54 -0
  47. package/compiled/debug/index.js +1 -0
  48. package/compiled/debug/ms/index.d.ts +25 -0
  49. package/compiled/debug/package.json +1 -0
  50. package/compiled/deepmerge/index.d.ts +16 -0
  51. package/compiled/deepmerge/index.js +1 -0
  52. package/compiled/deepmerge/package.json +1 -0
  53. package/compiled/execa/LICENSE +9 -0
  54. package/compiled/execa/index.d.ts +564 -0
  55. package/compiled/execa/index.js +1 -0
  56. package/compiled/execa/package.json +1 -0
  57. package/compiled/fs-extra/LICENSE +15 -0
  58. package/compiled/fs-extra/index.d.ts +332 -0
  59. package/compiled/fs-extra/index.js +1 -0
  60. package/compiled/fs-extra/package.json +1 -0
  61. package/compiled/glob/LICENSE +21 -0
  62. package/compiled/glob/index.d.ts +89 -0
  63. package/compiled/glob/index.js +1 -0
  64. package/compiled/glob/minimatch/index.d.ts +204 -0
  65. package/compiled/glob/package.json +1 -0
  66. package/compiled/import-lazy/LICENSE +9 -0
  67. package/compiled/import-lazy/index.d.ts +26 -0
  68. package/compiled/import-lazy/index.js +1 -0
  69. package/compiled/import-lazy/package.json +1 -0
  70. package/compiled/lodash/LICENSE +47 -0
  71. package/compiled/lodash/common/array.d.ts +2126 -0
  72. package/compiled/lodash/common/collection.d.ts +1930 -0
  73. package/compiled/lodash/common/common.d.ts +280 -0
  74. package/compiled/lodash/common/date.d.ts +23 -0
  75. package/compiled/lodash/common/function.d.ts +1430 -0
  76. package/compiled/lodash/common/lang.d.ts +1692 -0
  77. package/compiled/lodash/common/math.d.ts +405 -0
  78. package/compiled/lodash/common/number.d.ts +131 -0
  79. package/compiled/lodash/common/object.d.ts +2519 -0
  80. package/compiled/lodash/common/seq.d.ts +210 -0
  81. package/compiled/lodash/common/string.d.ts +788 -0
  82. package/compiled/lodash/common/util.d.ts +1219 -0
  83. package/compiled/lodash/index.d.ts +46 -0
  84. package/compiled/lodash/index.js +9 -0
  85. package/compiled/lodash/package.json +1 -0
  86. package/compiled/mustache/LICENSE +11 -0
  87. package/compiled/mustache/index.d.ts +437 -0
  88. package/compiled/mustache/index.js +5 -0
  89. package/compiled/mustache/package.json +1 -0
  90. package/compiled/pkg-up/LICENSE +9 -0
  91. package/compiled/pkg-up/index.d.ts +48 -0
  92. package/compiled/pkg-up/index.js +1 -0
  93. package/compiled/pkg-up/package.json +1 -0
  94. package/compiled/portfinder/LICENSE +22 -0
  95. package/compiled/portfinder/index.js +1 -0
  96. package/compiled/portfinder/lib/portfinder.d.ts +47 -0
  97. package/compiled/portfinder/package.json +1 -0
  98. package/compiled/prettier/LICENSE +7 -0
  99. package/compiled/prettier/index.d.ts +756 -0
  100. package/compiled/prettier/index.js +263 -0
  101. package/compiled/prettier/package.json +1 -0
  102. package/compiled/prompts/LICENSE +21 -0
  103. package/compiled/prompts/index.d.ts +120 -0
  104. package/compiled/prompts/index.js +1 -0
  105. package/compiled/prompts/package.json +1 -0
  106. package/compiled/resolve/LICENSE +21 -0
  107. package/compiled/resolve/index.d.ts +166 -0
  108. package/compiled/resolve/index.js +1 -0
  109. package/compiled/resolve/package.json +1 -0
  110. package/compiled/rimraf/LICENSE +15 -0
  111. package/compiled/rimraf/glob/index.d.ts +89 -0
  112. package/compiled/rimraf/index.d.ts +49 -0
  113. package/compiled/rimraf/index.js +1 -0
  114. package/compiled/rimraf/minimatch/index.d.ts +204 -0
  115. package/compiled/rimraf/package.json +1 -0
  116. package/compiled/semver/LICENSE +15 -0
  117. package/compiled/semver/classes/comparator.d.ts +17 -0
  118. package/compiled/semver/classes/range.d.ts +21 -0
  119. package/compiled/semver/classes/semver.d.ts +62 -0
  120. package/compiled/semver/functions/clean.d.ts +8 -0
  121. package/compiled/semver/functions/cmp.d.ts +16 -0
  122. package/compiled/semver/functions/coerce.d.ts +12 -0
  123. package/compiled/semver/functions/compare-build.d.ts +16 -0
  124. package/compiled/semver/functions/compare-loose.d.ts +5 -0
  125. package/compiled/semver/functions/compare.d.ts +20 -0
  126. package/compiled/semver/functions/diff.d.ts +13 -0
  127. package/compiled/semver/functions/eq.d.ts +9 -0
  128. package/compiled/semver/functions/gt.d.ts +9 -0
  129. package/compiled/semver/functions/gte.d.ts +9 -0
  130. package/compiled/semver/functions/inc.d.ts +15 -0
  131. package/compiled/semver/functions/lt.d.ts +9 -0
  132. package/compiled/semver/functions/lte.d.ts +8 -0
  133. package/compiled/semver/functions/major.d.ts +9 -0
  134. package/compiled/semver/functions/minor.d.ts +9 -0
  135. package/compiled/semver/functions/neq.d.ts +9 -0
  136. package/compiled/semver/functions/parse.d.ts +12 -0
  137. package/compiled/semver/functions/patch.d.ts +9 -0
  138. package/compiled/semver/functions/prerelease.d.ts +12 -0
  139. package/compiled/semver/functions/rcompare.d.ts +15 -0
  140. package/compiled/semver/functions/rsort.d.ts +9 -0
  141. package/compiled/semver/functions/satisfies.d.ts +14 -0
  142. package/compiled/semver/functions/sort.d.ts +9 -0
  143. package/compiled/semver/functions/valid.d.ts +11 -0
  144. package/compiled/semver/index.d.ts +133 -0
  145. package/compiled/semver/index.js +1 -0
  146. package/compiled/semver/internals/identifiers.d.ts +13 -0
  147. package/compiled/semver/package.json +1 -0
  148. package/compiled/semver/ranges/gtr.d.ts +14 -0
  149. package/compiled/semver/ranges/intersects.d.ts +13 -0
  150. package/compiled/semver/ranges/ltr.d.ts +14 -0
  151. package/compiled/semver/ranges/max-satisfying.d.ts +14 -0
  152. package/compiled/semver/ranges/min-satisfying.d.ts +14 -0
  153. package/compiled/semver/ranges/min-version.d.ts +10 -0
  154. package/compiled/semver/ranges/outside.d.ts +15 -0
  155. package/compiled/semver/ranges/simplify.d.ts +14 -0
  156. package/compiled/semver/ranges/subset.d.ts +13 -0
  157. package/compiled/semver/ranges/to-comparators.d.ts +9 -0
  158. package/compiled/semver/ranges/valid.d.ts +12 -0
  159. package/compiled/strip-ansi/LICENSE +9 -0
  160. package/compiled/strip-ansi/index.d.ts +17 -0
  161. package/compiled/strip-ansi/index.js +1 -0
  162. package/compiled/strip-ansi/package.json +1 -0
  163. package/compiled/yargs-parser/index.d.ts +112 -0
  164. package/compiled/yargs-parser/index.js +1 -0
  165. package/compiled/yargs-parser/package.json +1 -0
  166. package/dist/BaseGenerator/BaseGenerator.d.ts +18 -0
  167. package/dist/BaseGenerator/BaseGenerator.js +58 -0
  168. package/dist/BaseGenerator/generateFile.d.ts +8 -0
  169. package/dist/BaseGenerator/generateFile.js +25 -0
  170. package/{lib → dist}/Generator/Generator.d.ts +3 -3
  171. package/dist/Generator/Generator.js +74 -0
  172. package/dist/importLazy.d.ts +6 -0
  173. package/dist/importLazy.js +17 -0
  174. package/dist/index.d.ts +33 -0
  175. package/dist/index.js +88 -0
  176. package/dist/installDeps.d.ts +9 -0
  177. package/dist/installDeps.js +39 -0
  178. package/dist/logger.d.ts +14 -0
  179. package/dist/logger.js +39 -0
  180. package/dist/npmClient.d.ts +15 -0
  181. package/dist/npmClient.js +43 -0
  182. package/dist/randomColor/randomColor.d.ts +6 -0
  183. package/dist/randomColor/randomColor.js +19 -0
  184. package/dist/register.d.ts +6 -0
  185. package/dist/register.js +48 -0
  186. package/dist/updatePackageJSON.d.ts +5 -0
  187. package/dist/updatePackageJSON.js +21 -0
  188. package/dist/winPath.d.ts +1 -0
  189. package/dist/winPath.js +11 -0
  190. package/package.json +102 -18
  191. package/lib/BabelRegister/BabelRegister.d.ts +0 -9
  192. package/lib/BabelRegister/BabelRegister.js +0 -66
  193. package/lib/Generator/Generator.js +0 -120
  194. package/lib/cheerio/cheerio.d.ts +0 -2
  195. package/lib/cheerio/cheerio.js +0 -37
  196. package/lib/cleanRequireCache/cleanRequireCache.d.ts +0 -1
  197. package/lib/cleanRequireCache/cleanRequireCache.js +0 -40
  198. package/lib/compatESModuleRequire/compatESModuleRequire.d.ts +0 -7
  199. package/lib/compatESModuleRequire/compatESModuleRequire.js +0 -22
  200. package/lib/delay/delay.d.ts +0 -1
  201. package/lib/delay/delay.js +0 -22
  202. package/lib/getFile/getFile.d.ts +0 -22
  203. package/lib/getFile/getFile.js +0 -85
  204. package/lib/index.d.ts +0 -66
  205. package/lib/index.js +0 -619
  206. package/lib/isLernaPackage/isLernaPackage.d.ts +0 -1
  207. package/lib/isLernaPackage/isLernaPackage.js +0 -42
  208. package/lib/mergeConfig/mergeConfig.d.ts +0 -8
  209. package/lib/mergeConfig/mergeConfig.js +0 -42
  210. package/lib/parseRequireDeps/parseRequireDeps.d.ts +0 -1
  211. package/lib/parseRequireDeps/parseRequireDeps.js +0 -98
  212. package/lib/randomColor/randomColor.d.ts +0 -6
  213. package/lib/randomColor/randomColor.js +0 -42
  214. package/lib/routes.d.ts +0 -11
  215. package/lib/routes.js +0 -53
  216. package/lib/ssr.d.ts +0 -12
  217. package/lib/ssr.js +0 -41
  218. package/lib/types.d.ts +0 -7
  219. package/lib/types.js +0 -17
  220. package/lib/winEOL/winEOL.d.ts +0 -7
  221. package/lib/winEOL/winEOL.js +0 -39
  222. package/lib/winPath/winPath.d.ts +0 -1
  223. package/lib/winPath/winPath.js +0 -28
@@ -0,0 +1,644 @@
1
+ /**
2
+ * Methods for traversing the DOM structure.
3
+ *
4
+ * @module cheerio/traversing
5
+ */
6
+ import { Node, Element, Document } from '../../domhandler';
7
+ import type { Cheerio } from '../cheerio';
8
+ import type { AcceptedFilters } from '../types';
9
+ /**
10
+ * Get the descendants of each element in the current set of matched elements,
11
+ * filtered by a selector, jQuery object, or element.
12
+ *
13
+ * @category Traversing
14
+ * @example
15
+ *
16
+ * ```js
17
+ * $('#fruits').find('li').length;
18
+ * //=> 3
19
+ * $('#fruits').find($('.apple')).length;
20
+ * //=> 1
21
+ * ```
22
+ *
23
+ * @param selectorOrHaystack - Element to look for.
24
+ * @returns The found elements.
25
+ * @see {@link https://api.jquery.com/find/}
26
+ */
27
+ export declare function find<T extends Node>(this: Cheerio<T>, selectorOrHaystack?: string | Cheerio<Element> | Element): Cheerio<Element>;
28
+ /**
29
+ * Get the parent of each element in the current set of matched elements,
30
+ * optionally filtered by a selector.
31
+ *
32
+ * @category Traversing
33
+ * @example
34
+ *
35
+ * ```js
36
+ * $('.pear').parent().attr('id');
37
+ * //=> fruits
38
+ * ```
39
+ *
40
+ * @param selector - If specified filter for parent.
41
+ * @returns The parents.
42
+ * @see {@link https://api.jquery.com/parent/}
43
+ */
44
+ export declare const parent: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
45
+ /**
46
+ * Get a set of parents filtered by `selector` of each element in the current
47
+ * set of match elements.
48
+ *
49
+ * @category Traversing
50
+ * @example
51
+ *
52
+ * ```js
53
+ * $('.orange').parents().length;
54
+ * //=> 2
55
+ * $('.orange').parents('#fruits').length;
56
+ * //=> 1
57
+ * ```
58
+ *
59
+ * @param selector - If specified filter for parents.
60
+ * @returns The parents.
61
+ * @see {@link https://api.jquery.com/parents/}
62
+ */
63
+ export declare const parents: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
64
+ /**
65
+ * Get the ancestors of each element in the current set of matched elements, up
66
+ * to but not including the element matched by the selector, DOM node, or cheerio object.
67
+ *
68
+ * @category Traversing
69
+ * @example
70
+ *
71
+ * ```js
72
+ * $('.orange').parentsUntil('#food').length;
73
+ * //=> 1
74
+ * ```
75
+ *
76
+ * @param selector - Selector for element to stop at.
77
+ * @param filterSelector - Optional filter for parents.
78
+ * @returns The parents.
79
+ * @see {@link https://api.jquery.com/parentsUntil/}
80
+ */
81
+ export declare const parentsUntil: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | null | undefined, filterSelector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
82
+ /**
83
+ * For each element in the set, get the first element that matches the selector
84
+ * by testing the element itself and traversing up through its ancestors in the DOM tree.
85
+ *
86
+ * @category Traversing
87
+ * @example
88
+ *
89
+ * ```js
90
+ * $('.orange').closest();
91
+ * //=> []
92
+ *
93
+ * $('.orange').closest('.apple');
94
+ * // => []
95
+ *
96
+ * $('.orange').closest('li');
97
+ * //=> [<li class="orange">Orange</li>]
98
+ *
99
+ * $('.orange').closest('#fruits');
100
+ * //=> [<ul id="fruits"> ... </ul>]
101
+ * ```
102
+ *
103
+ * @param selector - Selector for the element to find.
104
+ * @returns The closest nodes.
105
+ * @see {@link https://api.jquery.com/closest/}
106
+ */
107
+ export declare function closest<T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Node>): Cheerio<Node>;
108
+ /**
109
+ * Gets the next sibling of the first selected element, optionally filtered by a selector.
110
+ *
111
+ * @category Traversing
112
+ * @example
113
+ *
114
+ * ```js
115
+ * $('.apple').next().hasClass('orange');
116
+ * //=> true
117
+ * ```
118
+ *
119
+ * @param selector - If specified filter for sibling.
120
+ * @returns The next nodes.
121
+ * @see {@link https://api.jquery.com/next/}
122
+ */
123
+ export declare const next: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
124
+ /**
125
+ * Gets all the following siblings of the first selected element, optionally
126
+ * filtered by a selector.
127
+ *
128
+ * @category Traversing
129
+ * @example
130
+ *
131
+ * ```js
132
+ * $('.apple').nextAll();
133
+ * //=> [<li class="orange">Orange</li>, <li class="pear">Pear</li>]
134
+ * $('.apple').nextAll('.orange');
135
+ * //=> [<li class="orange">Orange</li>]
136
+ * ```
137
+ *
138
+ * @param selector - If specified filter for siblings.
139
+ * @returns The next nodes.
140
+ * @see {@link https://api.jquery.com/nextAll/}
141
+ */
142
+ export declare const nextAll: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
143
+ /**
144
+ * Gets all the following siblings up to but not including the element matched
145
+ * by the selector, optionally filtered by another selector.
146
+ *
147
+ * @category Traversing
148
+ * @example
149
+ *
150
+ * ```js
151
+ * $('.apple').nextUntil('.pear');
152
+ * //=> [<li class="orange">Orange</li>]
153
+ * ```
154
+ *
155
+ * @param selector - Selector for element to stop at.
156
+ * @param filterSelector - If specified filter for siblings.
157
+ * @returns The next nodes.
158
+ * @see {@link https://api.jquery.com/nextUntil/}
159
+ */
160
+ export declare const nextUntil: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | null | undefined, filterSelector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
161
+ /**
162
+ * Gets the previous sibling of the first selected element optionally filtered
163
+ * by a selector.
164
+ *
165
+ * @category Traversing
166
+ * @example
167
+ *
168
+ * ```js
169
+ * $('.orange').prev().hasClass('apple');
170
+ * //=> true
171
+ * ```
172
+ *
173
+ * @param selector - If specified filter for siblings.
174
+ * @returns The previous nodes.
175
+ * @see {@link https://api.jquery.com/prev/}
176
+ */
177
+ export declare const prev: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
178
+ /**
179
+ * Gets all the preceding siblings of the first selected element, optionally
180
+ * filtered by a selector.
181
+ *
182
+ * @category Traversing
183
+ * @example
184
+ *
185
+ * ```js
186
+ * $('.pear').prevAll();
187
+ * //=> [<li class="orange">Orange</li>, <li class="apple">Apple</li>]
188
+ *
189
+ * $('.pear').prevAll('.orange');
190
+ * //=> [<li class="orange">Orange</li>]
191
+ * ```
192
+ *
193
+ * @param selector - If specified filter for siblings.
194
+ * @returns The previous nodes.
195
+ * @see {@link https://api.jquery.com/prevAll/}
196
+ */
197
+ export declare const prevAll: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
198
+ /**
199
+ * Gets all the preceding siblings up to but not including the element matched
200
+ * by the selector, optionally filtered by another selector.
201
+ *
202
+ * @category Traversing
203
+ * @example
204
+ *
205
+ * ```js
206
+ * $('.pear').prevUntil('.apple');
207
+ * //=> [<li class="orange">Orange</li>]
208
+ * ```
209
+ *
210
+ * @param selector - Selector for element to stop at.
211
+ * @param filterSelector - If specified filter for siblings.
212
+ * @returns The previous nodes.
213
+ * @see {@link https://api.jquery.com/prevUntil/}
214
+ */
215
+ export declare const prevUntil: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | null | undefined, filterSelector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
216
+ /**
217
+ * Get the siblings of each element (excluding the element) in the set of
218
+ * matched elements, optionally filtered by a selector.
219
+ *
220
+ * @category Traversing
221
+ * @example
222
+ *
223
+ * ```js
224
+ * $('.pear').siblings().length;
225
+ * //=> 2
226
+ *
227
+ * $('.pear').siblings('.orange').length;
228
+ * //=> 1
229
+ * ```
230
+ *
231
+ * @param selector - If specified filter for siblings.
232
+ * @returns The siblings.
233
+ * @see {@link https://api.jquery.com/siblings/}
234
+ */
235
+ export declare const siblings: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
236
+ /**
237
+ * Gets the children of the first selected element.
238
+ *
239
+ * @category Traversing
240
+ * @example
241
+ *
242
+ * ```js
243
+ * $('#fruits').children().length;
244
+ * //=> 3
245
+ *
246
+ * $('#fruits').children('.pear').text();
247
+ * //=> Pear
248
+ * ```
249
+ *
250
+ * @param selector - If specified filter for children.
251
+ * @returns The children.
252
+ * @see {@link https://api.jquery.com/children/}
253
+ */
254
+ export declare const children: <T extends Node>(this: Cheerio<T>, selector?: AcceptedFilters<Element> | undefined) => Cheerio<Element>;
255
+ /**
256
+ * Gets the children of each element in the set of matched elements, including
257
+ * text and comment nodes.
258
+ *
259
+ * @category Traversing
260
+ * @example
261
+ *
262
+ * ```js
263
+ * $('#fruits').contents().length;
264
+ * //=> 3
265
+ * ```
266
+ *
267
+ * @returns The children.
268
+ * @see {@link https://api.jquery.com/contents/}
269
+ */
270
+ export declare function contents<T extends Node>(this: Cheerio<T>): Cheerio<Node>;
271
+ /**
272
+ * Iterates over a cheerio object, executing a function for each matched
273
+ * element. When the callback is fired, the function is fired in the context of
274
+ * the DOM element, so `this` refers to the current element, which is equivalent
275
+ * to the function parameter `element`. To break out of the `each` loop early,
276
+ * return with `false`.
277
+ *
278
+ * @category Traversing
279
+ * @example
280
+ *
281
+ * ```js
282
+ * const fruits = [];
283
+ *
284
+ * $('li').each(function (i, elem) {
285
+ * fruits[i] = $(this).text();
286
+ * });
287
+ *
288
+ * fruits.join(', ');
289
+ * //=> Apple, Orange, Pear
290
+ * ```
291
+ *
292
+ * @param fn - Function to execute.
293
+ * @returns The instance itself, useful for chaining.
294
+ * @see {@link https://api.jquery.com/each/}
295
+ */
296
+ export declare function each<T>(this: Cheerio<T>, fn: (this: T, i: number, el: T) => void | boolean): Cheerio<T>;
297
+ /**
298
+ * Pass each element in the current matched set through a function, producing a
299
+ * new Cheerio object containing the return values. The function can return an
300
+ * individual data item or an array of data items to be inserted into the
301
+ * resulting set. If an array is returned, the elements inside the array are
302
+ * inserted into the set. If the function returns null or undefined, no element
303
+ * will be inserted.
304
+ *
305
+ * @category Traversing
306
+ * @example
307
+ *
308
+ * ```js
309
+ * $('li')
310
+ * .map(function (i, el) {
311
+ * // this === el
312
+ * return $(this).text();
313
+ * })
314
+ * .toArray()
315
+ * .join(' ');
316
+ * //=> "apple orange pear"
317
+ * ```
318
+ *
319
+ * @param fn - Function to execute.
320
+ * @returns The mapped elements, wrapped in a Cheerio collection.
321
+ * @see {@link https://api.jquery.com/map/}
322
+ */
323
+ export declare function map<T, M>(this: Cheerio<T>, fn: (this: T, i: number, el: T) => M[] | M | null | undefined): Cheerio<M>;
324
+ /**
325
+ * Iterates over a cheerio object, reducing the set of selector elements to
326
+ * those that match the selector or pass the function's test.
327
+ *
328
+ * This is the definition for using type guards; have a look below for other
329
+ * ways to invoke this method. The function is executed in the context of the
330
+ * selected element, so `this` refers to the current element.
331
+ *
332
+ * @category Traversing
333
+ * @example <caption>Function</caption>
334
+ *
335
+ * ```js
336
+ * $('li')
337
+ * .filter(function (i, el) {
338
+ * // this === el
339
+ * return $(this).attr('class') === 'orange';
340
+ * })
341
+ * .attr('class'); //=> orange
342
+ * ```
343
+ *
344
+ * @param match - Value to look for, following the rules above.
345
+ * @returns The filtered collection.
346
+ * @see {@link https://api.jquery.com/filter/}
347
+ */
348
+ export declare function filter<T, S extends T>(this: Cheerio<T>, match: (this: T, index: number, value: T) => value is S): Cheerio<S>;
349
+ /**
350
+ * Iterates over a cheerio object, reducing the set of selector elements to
351
+ * those that match the selector or pass the function's test.
352
+ *
353
+ * - When a Cheerio selection is specified, return only the elements contained in
354
+ * that selection.
355
+ * - When an element is specified, return only that element (if it is contained in
356
+ * the original selection).
357
+ * - If using the function method, the function is executed in the context of the
358
+ * selected element, so `this` refers to the current element.
359
+ *
360
+ * @category Traversing
361
+ * @example <caption>Selector</caption>
362
+ *
363
+ * ```js
364
+ * $('li').filter('.orange').attr('class');
365
+ * //=> orange
366
+ * ```
367
+ *
368
+ * @example <caption>Function</caption>
369
+ *
370
+ * ```js
371
+ * $('li')
372
+ * .filter(function (i, el) {
373
+ * // this === el
374
+ * return $(this).attr('class') === 'orange';
375
+ * })
376
+ * .attr('class'); //=> orange
377
+ * ```
378
+ *
379
+ * @param match - Value to look for, following the rules above. See
380
+ * {@link AcceptedFilters}.
381
+ * @returns The filtered collection.
382
+ * @see {@link https://api.jquery.com/filter/}
383
+ */
384
+ export declare function filter<T, S extends AcceptedFilters<T>>(this: Cheerio<T>, match: S): Cheerio<S extends string ? Element : T>;
385
+ export declare function filterArray<T>(nodes: T[], match: AcceptedFilters<T>, xmlMode?: boolean, root?: Document): Element[] | T[];
386
+ /**
387
+ * Checks the current list of elements and returns `true` if *any* of the
388
+ * elements match the selector. If using an element or Cheerio selection,
389
+ * returns `true` if *any* of the elements match. If using a predicate function,
390
+ * the function is executed in the context of the selected element, so `this`
391
+ * refers to the current element.
392
+ *
393
+ * @category Attributes
394
+ * @param selector - Selector for the selection.
395
+ * @returns Whether or not the selector matches an element of the instance.
396
+ * @see {@link https://api.jquery.com/is/}
397
+ */
398
+ export declare function is<T>(this: Cheerio<T>, selector?: AcceptedFilters<T>): boolean;
399
+ /**
400
+ * Remove elements from the set of matched elements. Given a Cheerio object that
401
+ * represents a set of DOM elements, the `.not()` method constructs a new
402
+ * Cheerio object from a subset of the matching elements. The supplied selector
403
+ * is tested against each element; the elements that don't match the selector
404
+ * will be included in the result.
405
+ *
406
+ * The `.not()` method can take a function as its argument in the same way that
407
+ * `.filter()` does. Elements for which the function returns `true` are excluded
408
+ * from the filtered set; all other elements are included.
409
+ *
410
+ * @category Traversing
411
+ * @example <caption>Selector</caption>
412
+ *
413
+ * ```js
414
+ * $('li').not('.apple').length;
415
+ * //=> 2
416
+ * ```
417
+ *
418
+ * @example <caption>Function</caption>
419
+ *
420
+ * ```js
421
+ * $('li').not(function (i, el) {
422
+ * // this === el
423
+ * return $(this).attr('class') === 'orange';
424
+ * }).length; //=> 2
425
+ * ```
426
+ *
427
+ * @param match - Value to look for, following the rules above.
428
+ * @param container - Optional node to filter instead.
429
+ * @returns The filtered collection.
430
+ * @see {@link https://api.jquery.com/not/}
431
+ */
432
+ export declare function not<T extends Node>(this: Cheerio<T>, match: AcceptedFilters<T>): Cheerio<T>;
433
+ /**
434
+ * Filters the set of matched elements to only those which have the given DOM
435
+ * element as a descendant or which have a descendant that matches the given
436
+ * selector. Equivalent to `.filter(':has(selector)')`.
437
+ *
438
+ * @category Traversing
439
+ * @example <caption>Selector</caption>
440
+ *
441
+ * ```js
442
+ * $('ul').has('.pear').attr('id');
443
+ * //=> fruits
444
+ * ```
445
+ *
446
+ * @example <caption>Element</caption>
447
+ *
448
+ * ```js
449
+ * $('ul').has($('.pear')[0]).attr('id');
450
+ * //=> fruits
451
+ * ```
452
+ *
453
+ * @param selectorOrHaystack - Element to look for.
454
+ * @returns The filtered collection.
455
+ * @see {@link https://api.jquery.com/has/}
456
+ */
457
+ export declare function has(this: Cheerio<Node | Element>, selectorOrHaystack: string | Cheerio<Element> | Element): Cheerio<Node | Element>;
458
+ /**
459
+ * Will select the first element of a cheerio object.
460
+ *
461
+ * @category Traversing
462
+ * @example
463
+ *
464
+ * ```js
465
+ * $('#fruits').children().first().text();
466
+ * //=> Apple
467
+ * ```
468
+ *
469
+ * @returns The first element.
470
+ * @see {@link https://api.jquery.com/first/}
471
+ */
472
+ export declare function first<T extends Node>(this: Cheerio<T>): Cheerio<T>;
473
+ /**
474
+ * Will select the last element of a cheerio object.
475
+ *
476
+ * @category Traversing
477
+ * @example
478
+ *
479
+ * ```js
480
+ * $('#fruits').children().last().text();
481
+ * //=> Pear
482
+ * ```
483
+ *
484
+ * @returns The last element.
485
+ * @see {@link https://api.jquery.com/last/}
486
+ */
487
+ export declare function last<T>(this: Cheerio<T>): Cheerio<T>;
488
+ /**
489
+ * Reduce the set of matched elements to the one at the specified index. Use
490
+ * `.eq(-i)` to count backwards from the last selected element.
491
+ *
492
+ * @category Traversing
493
+ * @example
494
+ *
495
+ * ```js
496
+ * $('li').eq(0).text();
497
+ * //=> Apple
498
+ *
499
+ * $('li').eq(-1).text();
500
+ * //=> Pear
501
+ * ```
502
+ *
503
+ * @param i - Index of the element to select.
504
+ * @returns The element at the `i`th position.
505
+ * @see {@link https://api.jquery.com/eq/}
506
+ */
507
+ export declare function eq<T>(this: Cheerio<T>, i: number): Cheerio<T>;
508
+ /**
509
+ * Retrieve one of the elements matched by the Cheerio object, at the `i`th position.
510
+ *
511
+ * @category Traversing
512
+ * @example
513
+ *
514
+ * ```js
515
+ * $('li').get(0).tagName;
516
+ * //=> li
517
+ * ```
518
+ *
519
+ * @param i - Element to retrieve.
520
+ * @returns The element at the `i`th position.
521
+ * @see {@link https://api.jquery.com/get/}
522
+ */
523
+ export declare function get<T>(this: Cheerio<T>, i: number): T;
524
+ /**
525
+ * Retrieve all elements matched by the Cheerio object, as an array.
526
+ *
527
+ * @category Traversing
528
+ * @example
529
+ *
530
+ * ```js
531
+ * $('li').get().length;
532
+ * //=> 3
533
+ * ```
534
+ *
535
+ * @returns All elements matched by the Cheerio object.
536
+ * @see {@link https://api.jquery.com/get/}
537
+ */
538
+ export declare function get<T>(this: Cheerio<T>): T[];
539
+ /**
540
+ * Retrieve all the DOM elements contained in the jQuery set as an array.
541
+ *
542
+ * @example
543
+ *
544
+ * ```js
545
+ * $('li').toArray();
546
+ * //=> [ {...}, {...}, {...} ]
547
+ * ```
548
+ *
549
+ * @returns The contained items.
550
+ */
551
+ export declare function toArray<T>(this: Cheerio<T>): T[];
552
+ /**
553
+ * Search for a given element from among the matched elements.
554
+ *
555
+ * @category Traversing
556
+ * @example
557
+ *
558
+ * ```js
559
+ * $('.pear').index();
560
+ * //=> 2 $('.orange').index('li');
561
+ * //=> 1
562
+ * $('.apple').index($('#fruit, li'));
563
+ * //=> 1
564
+ * ```
565
+ *
566
+ * @param selectorOrNeedle - Element to look for.
567
+ * @returns The index of the element.
568
+ * @see {@link https://api.jquery.com/index/}
569
+ */
570
+ export declare function index<T extends Node>(this: Cheerio<T>, selectorOrNeedle?: string | Cheerio<Node> | Node): number;
571
+ /**
572
+ * Gets the elements matching the specified range (0-based position).
573
+ *
574
+ * @category Traversing
575
+ * @example
576
+ *
577
+ * ```js
578
+ * $('li').slice(1).eq(0).text();
579
+ * //=> 'Orange'
580
+ *
581
+ * $('li').slice(1, 2).length;
582
+ * //=> 1
583
+ * ```
584
+ *
585
+ * @param start - An position at which the elements begin to be selected. If
586
+ * negative, it indicates an offset from the end of the set.
587
+ * @param end - An position at which the elements stop being selected. If
588
+ * negative, it indicates an offset from the end of the set. If omitted, the
589
+ * range continues until the end of the set.
590
+ * @returns The elements matching the specified range.
591
+ * @see {@link https://api.jquery.com/slice/}
592
+ */
593
+ export declare function slice<T>(this: Cheerio<T>, start?: number, end?: number): Cheerio<T>;
594
+ /**
595
+ * End the most recent filtering operation in the current chain and return the
596
+ * set of matched elements to its previous state.
597
+ *
598
+ * @category Traversing
599
+ * @example
600
+ *
601
+ * ```js
602
+ * $('li').eq(0).end().length;
603
+ * //=> 3
604
+ * ```
605
+ *
606
+ * @returns The previous state of the set of matched elements.
607
+ * @see {@link https://api.jquery.com/end/}
608
+ */
609
+ export declare function end<T>(this: Cheerio<T>): Cheerio<Node>;
610
+ /**
611
+ * Add elements to the set of matched elements.
612
+ *
613
+ * @category Traversing
614
+ * @example
615
+ *
616
+ * ```js
617
+ * $('.apple').add('.orange').length;
618
+ * //=> 2
619
+ * ```
620
+ *
621
+ * @param other - Elements to add.
622
+ * @param context - Optionally the context of the new selection.
623
+ * @returns The combined set.
624
+ * @see {@link https://api.jquery.com/add/}
625
+ */
626
+ export declare function add<S extends Node, T extends Node>(this: Cheerio<T>, other: string | Cheerio<S> | S | S[], context?: Cheerio<S> | string): Cheerio<S | T>;
627
+ /**
628
+ * Add the previous set of elements on the stack to the current set, optionally
629
+ * filtered by a selector.
630
+ *
631
+ * @category Traversing
632
+ * @example
633
+ *
634
+ * ```js
635
+ * $('li').eq(0).addBack('.orange').length;
636
+ * //=> 2
637
+ * ```
638
+ *
639
+ * @param selector - Selector for the elements to add.
640
+ * @returns The combined set.
641
+ * @see {@link https://api.jquery.com/addBack/}
642
+ */
643
+ export declare function addBack<T extends Node>(this: Cheerio<T>, selector?: string): Cheerio<Node>;
644
+ //# sourceMappingURL=traversing.d.ts.map
@@ -0,0 +1,53 @@
1
+ import { InternalOptions } from './options';
2
+ import type { Node, Document } from '../domhandler';
3
+ import { BasicAcceptedElems } from './types';
4
+ import * as Attributes from './api/attributes';
5
+ import * as Traversing from './api/traversing';
6
+ import * as Manipulation from './api/manipulation';
7
+ import * as Css from './api/css';
8
+ import * as Forms from './api/forms';
9
+ declare type AttributesType = typeof Attributes;
10
+ declare type TraversingType = typeof Traversing;
11
+ declare type ManipulationType = typeof Manipulation;
12
+ declare type CssType = typeof Css;
13
+ declare type FormsType = typeof Forms;
14
+ export declare class Cheerio<T> implements ArrayLike<T> {
15
+ length: number;
16
+ [index: number]: T;
17
+ options: InternalOptions;
18
+ /**
19
+ * The root of the document. Can be set by using the `root` argument of the constructor.
20
+ *
21
+ * @private
22
+ */
23
+ _root: Cheerio<Document> | undefined;
24
+ /** @function */
25
+ find: typeof Traversing.find;
26
+ /**
27
+ * Instance of cheerio. Methods are specified in the modules. Usage of this
28
+ * constructor is not recommended. Please use $.load instead.
29
+ *
30
+ * @private
31
+ * @param selector - The new selection.
32
+ * @param context - Context of the selection.
33
+ * @param root - Sets the root node.
34
+ * @param options - Options for the instance.
35
+ */
36
+ constructor(selector?: T extends Node ? BasicAcceptedElems<T> : Cheerio<T> | T[], context?: BasicAcceptedElems<Node> | null, root?: BasicAcceptedElems<Document> | null, options?: InternalOptions);
37
+ prevObject: Cheerio<Node> | undefined;
38
+ /**
39
+ * Make a cheerio object.
40
+ *
41
+ * @private
42
+ * @param dom - The contents of the new object.
43
+ * @param context - The context of the new object.
44
+ * @returns The new cheerio object.
45
+ */
46
+ _make<T>(dom: Cheerio<T> | T[] | T | string, context?: BasicAcceptedElems<Node>): Cheerio<T>;
47
+ }
48
+ export interface Cheerio<T> extends AttributesType, TraversingType, ManipulationType, CssType, FormsType, Iterable<T> {
49
+ cheerio: '[cheerio object]';
50
+ splice: typeof Array.prototype.slice;
51
+ }
52
+ export {};
53
+ //# sourceMappingURL=cheerio.d.ts.map