index.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. "use strict";
  2. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  3. if (k2 === undefined) k2 = k;
  4. var desc = Object.getOwnPropertyDescriptor(m, k);
  5. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  6. desc = { enumerable: true, get: function() { return m[k]; } };
  7. }
  8. Object.defineProperty(o, k2, desc);
  9. }) : (function(o, m, k, k2) {
  10. if (k2 === undefined) k2 = k;
  11. o[k2] = m[k];
  12. }));
  13. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  14. Object.defineProperty(o, "default", { enumerable: true, value: v });
  15. }) : function(o, v) {
  16. o["default"] = v;
  17. });
  18. var __exportStar = (this && this.__exportStar) || function(m, exports) {
  19. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  20. };
  21. var __importStar = (this && this.__importStar) || function (mod) {
  22. if (mod && mod.__esModule) return mod;
  23. var result = {};
  24. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  25. __setModuleDefault(result, mod);
  26. return result;
  27. };
  28. var __importDefault = (this && this.__importDefault) || function (mod) {
  29. return (mod && mod.__esModule) ? mod : { "default": mod };
  30. };
  31. Object.defineProperty(exports, "__esModule", { value: true });
  32. exports.root = exports.parseHTML = exports.merge = exports.contains = exports.text = exports.xml = exports.html = exports.load = void 0;
  33. /**
  34. * Types used in signatures of Cheerio methods.
  35. *
  36. * @category Cheerio
  37. */
  38. __exportStar(require("./types.js"), exports);
  39. var load_js_1 = require("./load.js");
  40. var parse_js_1 = require("./parse.js");
  41. var parse5_adapter_js_1 = require("./parsers/parse5-adapter.js");
  42. var dom_serializer_1 = __importDefault(require("dom-serializer"));
  43. var htmlparser2_1 = require("htmlparser2");
  44. var parse = (0, parse_js_1.getParse)(function (content, options, isDocument, context) {
  45. return options.xmlMode || options._useHtmlParser2
  46. ? (0, htmlparser2_1.parseDocument)(content, options)
  47. : (0, parse5_adapter_js_1.parseWithParse5)(content, options, isDocument, context);
  48. });
  49. // Duplicate docs due to https://github.com/TypeStrong/typedoc/issues/1616
  50. /**
  51. * Create a querying function, bound to a document created from the provided markup.
  52. *
  53. * Note that similar to web browser contexts, this operation may introduce
  54. * `<html>`, `<head>`, and `<body>` elements; set `isDocument` to `false` to
  55. * switch to fragment mode and disable this.
  56. *
  57. * @param content - Markup to be loaded.
  58. * @param options - Options for the created instance.
  59. * @param isDocument - Allows parser to be switched to fragment mode.
  60. * @returns The loaded document.
  61. * @see {@link https://cheerio.js.org#loading} for additional usage information.
  62. */
  63. exports.load = (0, load_js_1.getLoad)(parse, function (dom, options) {
  64. return options.xmlMode || options._useHtmlParser2
  65. ? (0, dom_serializer_1.default)(dom, options)
  66. : (0, parse5_adapter_js_1.renderWithParse5)(dom);
  67. });
  68. /**
  69. * The default cheerio instance.
  70. *
  71. * @deprecated Use the function returned by `load` instead.
  72. */
  73. exports.default = (0, exports.load)([]);
  74. var static_js_1 = require("./static.js");
  75. Object.defineProperty(exports, "html", { enumerable: true, get: function () { return static_js_1.html; } });
  76. Object.defineProperty(exports, "xml", { enumerable: true, get: function () { return static_js_1.xml; } });
  77. Object.defineProperty(exports, "text", { enumerable: true, get: function () { return static_js_1.text; } });
  78. var staticMethods = __importStar(require("./static.js"));
  79. /**
  80. * In order to promote consistency with the jQuery library, users are encouraged
  81. * to instead use the static method of the same name.
  82. *
  83. * @deprecated
  84. * @example
  85. *
  86. * ```js
  87. * const $ = cheerio.load('<div><p></p></div>');
  88. *
  89. * $.contains($('div').get(0), $('p').get(0));
  90. * //=> true
  91. *
  92. * $.contains($('p').get(0), $('div').get(0));
  93. * //=> false
  94. * ```
  95. *
  96. * @returns {boolean}
  97. */
  98. exports.contains = staticMethods.contains;
  99. /**
  100. * In order to promote consistency with the jQuery library, users are encouraged
  101. * to instead use the static method of the same name.
  102. *
  103. * @deprecated
  104. * @example
  105. *
  106. * ```js
  107. * const $ = cheerio.load('');
  108. *
  109. * $.merge([1, 2], [3, 4]);
  110. * //=> [1, 2, 3, 4]
  111. * ```
  112. */
  113. exports.merge = staticMethods.merge;
  114. /**
  115. * In order to promote consistency with the jQuery library, users are encouraged
  116. * to instead use the static method of the same name as it is defined on the
  117. * "loaded" Cheerio factory function.
  118. *
  119. * @deprecated See {@link static/parseHTML}.
  120. * @example
  121. *
  122. * ```js
  123. * const $ = cheerio.load('');
  124. * $.parseHTML('<b>markup</b>');
  125. * ```
  126. */
  127. exports.parseHTML = staticMethods.parseHTML;
  128. /**
  129. * Users seeking to access the top-level element of a parsed document should
  130. * instead use the `root` static method of a "loaded" Cheerio function.
  131. *
  132. * @deprecated
  133. * @example
  134. *
  135. * ```js
  136. * const $ = cheerio.load('');
  137. * $.root();
  138. * ```
  139. */
  140. exports.root = staticMethods.root;
  141. //# sourceMappingURL=index.js.map