SourceAndMapMixin.js 817 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. module.exports = function mixinSourceAndMap(proto) {
  7. proto.map = function(options) {
  8. options = options || {};
  9. if(options.columns === false) {
  10. return this.listMap(options).toStringWithSourceMap({
  11. file: "x"
  12. }).map;
  13. }
  14. return this.node(options).toStringWithSourceMap({
  15. file: "x"
  16. }).map.toJSON();
  17. };
  18. proto.sourceAndMap = function(options) {
  19. options = options || {};
  20. if(options.columns === false) {
  21. //console.log(this.listMap(options).debugInfo());
  22. return this.listMap(options).toStringWithSourceMap({
  23. file: "x"
  24. });
  25. }
  26. var res = this.node(options).toStringWithSourceMap({
  27. file: "x"
  28. });
  29. return {
  30. source: res.code,
  31. map: res.map.toJSON()
  32. };
  33. };
  34. }