getSource.js 422 B

1234567891011121314151617
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const getSource = (sourceMap, index) => {
  7. if (index < 0) return null;
  8. const { sourceRoot, sources } = sourceMap;
  9. const source = sources[index];
  10. if (!sourceRoot) return source;
  11. if (sourceRoot.endsWith("/")) return sourceRoot + source;
  12. return sourceRoot + "/" + source;
  13. };
  14. module.exports = getSource;