Source.js 669 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. return this.source().length;
  14. }
  15. map(options) {
  16. return null;
  17. }
  18. sourceAndMap(options) {
  19. return {
  20. source: this.source(),
  21. map: this.map()
  22. };
  23. }
  24. node() {
  25. throw new Error("Abstract");
  26. }
  27. listNode() {
  28. throw new Error("Abstract");
  29. }
  30. updateHash(hash) {
  31. var source = this.source();
  32. hash.update(source || "");
  33. }
  34. }
  35. module.exports = Source;