public_library_map/node_modules/cheerio/lib/utils.d.ts

75 lines
2.2 KiB
TypeScript
Raw Normal View History

2022-09-03 17:12:22 +10:00
import { type AnyNode } from 'domhandler';
import type { Cheerio } from './cheerio.js';
2021-11-24 19:46:47 +11:00
/**
* Check if the DOM element is a tag.
*
* `isTag(type)` includes `<script>` and `<style>` tags.
*
* @private
* @category Utils
2022-09-03 17:12:22 +10:00
* @param type - The DOM node to check.
2021-11-24 19:46:47 +11:00
* @returns Whether the node is a tag.
*/
2022-09-03 17:12:22 +10:00
export { isTag } from 'domhandler';
2021-11-24 19:46:47 +11:00
/**
* Checks if an object is a Cheerio instance.
*
* @category Utils
* @param maybeCheerio - The object to check.
* @returns Whether the object is a Cheerio instance.
*/
export declare function isCheerio<T>(maybeCheerio: any): maybeCheerio is Cheerio<T>;
/**
* Convert a string to camel case notation.
*
* @private
* @category Utils
2022-09-03 17:12:22 +10:00
* @param str - The string to be converted.
2021-11-24 19:46:47 +11:00
* @returns String in camel case notation.
*/
export declare function camelCase(str: string): string;
/**
* Convert a string from camel case to "CSS case", where word boundaries are
* described by hyphens ("-") and all characters are lower-case.
*
* @private
* @category Utils
2022-09-03 17:12:22 +10:00
* @param str - The string to be converted.
2021-11-24 19:46:47 +11:00
* @returns String in "CSS case".
*/
export declare function cssCase(str: string): string;
/**
* Iterate over each DOM element without creating intermediary Cheerio instances.
*
* This is indented for use internally to avoid otherwise unnecessary memory
* pressure introduced by _make.
*
* @category Utils
2022-09-03 17:12:22 +10:00
* @param array - The array to iterate over.
2021-11-24 19:46:47 +11:00
* @param fn - Function to call.
* @returns The original instance.
*/
2022-09-03 17:12:22 +10:00
export declare function domEach<T extends AnyNode, Arr extends ArrayLike<T> = Cheerio<T>>(array: Arr, fn: (elem: T, index: number) => void): Arr;
2021-11-24 19:46:47 +11:00
/**
* Create a deep copy of the given DOM structure. Sets the parents of the copies
* of the passed nodes to `null`.
*
* @private
* @category Utils
2022-09-03 17:12:22 +10:00
* @param dom - The domhandler-compliant DOM structure.
2021-11-24 19:46:47 +11:00
* @returns - The cloned DOM.
*/
2022-09-03 17:12:22 +10:00
export declare function cloneDom<T extends AnyNode>(dom: T | T[]): T[];
2021-11-24 19:46:47 +11:00
/**
* Check if string is HTML.
*
2022-09-03 17:12:22 +10:00
* Tests for a `<` within a string, immediate followed by a letter and
* eventually followed by a `>`.
*
2021-11-24 19:46:47 +11:00
* @private
* @category Utils
2022-09-03 17:12:22 +10:00
* @param str - The string to check.
2021-11-24 19:46:47 +11:00
* @returns Indicates if `str` is HTML.
*/
export declare function isHtml(str: string): boolean;
//# sourceMappingURL=utils.d.ts.map