SizeOnlySource.js 602 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const Source = require("./Source");
  7. class SizeOnlySource extends Source {
  8. constructor(size) {
  9. super();
  10. this._size = size;
  11. }
  12. _error() {
  13. return new Error(
  14. "Content and Map of this Source is not available (only size() is supported)"
  15. );
  16. }
  17. size() {
  18. return this._size;
  19. }
  20. source() {
  21. throw this._error();
  22. }
  23. buffer() {
  24. throw this._error();
  25. }
  26. map(options) {
  27. throw this._error();
  28. }
  29. updateHash() {
  30. throw this._error();
  31. }
  32. }
  33. module.exports = SizeOnlySource;