stripComments.js 521 B

123456789101112131415161718192021
  1. "use strict";
  2. exports.__esModule = true;
  3. exports["default"] = stripComments;
  4. function stripComments(str) {
  5. var s = "";
  6. var commentStart = str.indexOf("/*");
  7. var lastEnd = 0;
  8. while (commentStart >= 0) {
  9. s = s + str.slice(lastEnd, commentStart);
  10. var commentEnd = str.indexOf("*/", commentStart + 2);
  11. if (commentEnd < 0) {
  12. return s;
  13. }
  14. lastEnd = commentEnd + 2;
  15. commentStart = str.indexOf("/*", lastEnd);
  16. }
  17. s = s + str.slice(lastEnd);
  18. return s;
  19. }
  20. module.exports = exports.default;