You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
752 B

4 years ago
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. var SourceNode = require("source-map").SourceNode;
  7. var SourceMapConsumer = require("source-map").SourceMapConsumer;
  8. class Source {
  9. source() {
  10. throw new Error("Abstract");
  11. }
  12. size() {
  13. if(Buffer.from.length === 1) return new Buffer(this.source()).length;
  14. return Buffer.byteLength(this.source())
  15. }
  16. map(options) {
  17. return null;
  18. }
  19. sourceAndMap(options) {
  20. return {
  21. source: this.source(),
  22. map: this.map()
  23. };
  24. }
  25. node() {
  26. throw new Error("Abstract");
  27. }
  28. listNode() {
  29. throw new Error("Abstract");
  30. }
  31. updateHash(hash) {
  32. var source = this.source();
  33. hash.update(source || "");
  34. }
  35. }
  36. module.exports = Source;