MappingsContext.js 657 B

123456789101112131415161718192021222324
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. function MappingsContext() {
  6. this.sources = [];
  7. this.sourcesContent = [];
  8. this.hasSourceContent = false;
  9. this.currentOriginalLine = 1;
  10. this.currentSource = 0;
  11. }
  12. module.exports = MappingsContext;
  13. MappingsContext.prototype.ensureSource = function(source, originalSource) {
  14. var idx = this.sources.indexOf(source);
  15. if(idx >= 0)
  16. return idx;
  17. idx = this.sources.length;
  18. this.sources.push(source);
  19. this.sourcesContent.push(originalSource);
  20. if(typeof originalSource === "string")
  21. this.hasSourceContent = true;
  22. return idx;
  23. };