73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
import { DomUtils } from 'htmlparser2';
|
|
import { Node } from 'domhandler';
|
|
import type { Cheerio } from './cheerio';
|
|
/**
|
|
* Check if the DOM element is a tag.
|
|
*
|
|
* `isTag(type)` includes `<script>` and `<style>` tags.
|
|
*
|
|
* @private
|
|
* @category Utils
|
|
* @param type - DOM node to check.
|
|
* @returns Whether the node is a tag.
|
|
*/
|
|
export declare const isTag: typeof DomUtils.isTag;
|
|
/**
|
|
* 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
|
|
* @param str - String to be converted.
|
|
* @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
|
|
* @param str - String to be converted.
|
|
* @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
|
|
* @param array - Array to iterate over.
|
|
* @param fn - Function to call.
|
|
* @returns The original instance.
|
|
*/
|
|
export declare function domEach<T extends Node, Arr extends ArrayLike<T> = Cheerio<T>>(array: Arr, fn: (elem: T, index: number) => void): Arr;
|
|
/**
|
|
* Create a deep copy of the given DOM structure. Sets the parents of the copies
|
|
* of the passed nodes to `null`.
|
|
*
|
|
* @private
|
|
* @category Utils
|
|
* @param dom - The htmlparser2-compliant DOM structure.
|
|
* @returns - The cloned DOM.
|
|
*/
|
|
export declare function cloneDom<T extends Node>(dom: T | T[]): T[];
|
|
/**
|
|
* Check if string is HTML.
|
|
*
|
|
* @private
|
|
* @category Utils
|
|
* @param str - String to check.
|
|
* @returns Indicates if `str` is HTML.
|
|
*/
|
|
export declare function isHtml(str: string): boolean;
|
|
//# sourceMappingURL=utils.d.ts.map
|