ContentFolder.js 723 B

12345678910111213141516171819202122232425262728293031323334
  1. import BaseFolder from './BaseFolder';
  2. export default class ContentFolder extends BaseFolder {
  3. constructor(name, ownerModule, parent) {
  4. super(name, parent);
  5. this.ownerModule = ownerModule;
  6. }
  7. get parsedSize() {
  8. return this.getSize('parsedSize');
  9. }
  10. get gzipSize() {
  11. return this.getSize('gzipSize');
  12. }
  13. getSize(sizeType) {
  14. const ownerModuleSize = this.ownerModule[sizeType];
  15. if (ownerModuleSize !== undefined) {
  16. return Math.floor((this.size / this.ownerModule.size) * ownerModuleSize);
  17. }
  18. return;
  19. }
  20. toChartData() {
  21. return {
  22. ...super.toChartData(),
  23. parsedSize: this.parsedSize,
  24. gzipSize: this.gzipSize,
  25. inaccurateSizes: true,
  26. };
  27. }
  28. }