cheerio.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 __importStar = (this && this.__importStar) || function (mod) {
  19. if (mod && mod.__esModule) return mod;
  20. var result = {};
  21. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  22. __setModuleDefault(result, mod);
  23. return result;
  24. };
  25. Object.defineProperty(exports, "__esModule", { value: true });
  26. exports.Cheerio = void 0;
  27. var Attributes = __importStar(require("./api/attributes.js"));
  28. var Traversing = __importStar(require("./api/traversing.js"));
  29. var Manipulation = __importStar(require("./api/manipulation.js"));
  30. var Css = __importStar(require("./api/css.js"));
  31. var Forms = __importStar(require("./api/forms.js"));
  32. var Cheerio = /** @class */ (function () {
  33. /**
  34. * Instance of cheerio. Methods are specified in the modules. Usage of this
  35. * constructor is not recommended. Please use `$.load` instead.
  36. *
  37. * @private
  38. * @param elements - The new selection.
  39. * @param root - Sets the root node.
  40. * @param options - Options for the instance.
  41. */
  42. function Cheerio(elements, root, options) {
  43. this.length = 0;
  44. this.options = options;
  45. this._root = root;
  46. if (elements) {
  47. for (var idx = 0; idx < elements.length; idx++) {
  48. this[idx] = elements[idx];
  49. }
  50. this.length = elements.length;
  51. }
  52. }
  53. return Cheerio;
  54. }());
  55. exports.Cheerio = Cheerio;
  56. /** Set a signature of the object. */
  57. Cheerio.prototype.cheerio = '[cheerio object]';
  58. /*
  59. * Make cheerio an array-like object
  60. */
  61. Cheerio.prototype.splice = Array.prototype.splice;
  62. // Support for (const element of $(...)) iteration:
  63. Cheerio.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
  64. // Plug in the API
  65. Object.assign(Cheerio.prototype, Attributes, Traversing, Manipulation, Css, Forms);
  66. //# sourceMappingURL=cheerio.js.map