ContentModule.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _Module = _interopRequireDefault(require("./Module"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  9. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  10. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  11. class ContentModule extends _Module.default {
  12. constructor(name, data, ownerModule, parent) {
  13. super(name, data, parent);
  14. this.ownerModule = ownerModule;
  15. }
  16. get parsedSize() {
  17. return this.getSize('parsedSize');
  18. }
  19. get gzipSize() {
  20. return this.getSize('gzipSize');
  21. }
  22. getSize(sizeType) {
  23. const ownerModuleSize = this.ownerModule[sizeType];
  24. if (ownerModuleSize !== undefined) {
  25. return Math.floor(this.size / this.ownerModule.size * ownerModuleSize);
  26. }
  27. }
  28. toChartData() {
  29. return _objectSpread({}, super.toChartData(), {
  30. inaccurateSizes: true
  31. });
  32. }
  33. }
  34. exports.default = ContentModule;
  35. ;