utils.d.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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: any): 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