root.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. var __importDefault = (this && this.__importDefault) || function (mod) {
  18. return (mod && mod.__esModule) ? mod : { "default": mod };
  19. };
  20. Object.defineProperty(exports, "__esModule", { value: true });
  21. var container_1 = __importDefault(require("./container"));
  22. var types_1 = require("./types");
  23. var Root = /** @class */ (function (_super) {
  24. __extends(Root, _super);
  25. function Root(opts) {
  26. var _this = _super.call(this, opts) || this;
  27. _this.type = types_1.ROOT;
  28. return _this;
  29. }
  30. Root.prototype._stringify = function (options, depth, max) {
  31. var _this = this;
  32. var str = this.reduce(function (memo, selector) {
  33. memo.push(_this._stringifyChild(selector, options, depth, max));
  34. return memo;
  35. }, []).join(",");
  36. return this.trailingComma ? str + "," : str;
  37. };
  38. Root.prototype.error = function (message, options) {
  39. if (this._error) {
  40. return this._error(message, options);
  41. }
  42. else {
  43. return new Error(message);
  44. }
  45. };
  46. Object.defineProperty(Root.prototype, "errorGenerator", {
  47. set: function (handler) {
  48. this._error = handler;
  49. },
  50. enumerable: false,
  51. configurable: true
  52. });
  53. return Root;
  54. }(container_1.default));
  55. exports.default = Root;
  56. //# sourceMappingURL=root.js.map