commentParser.js 674 B

12345678910111213141516171819202122232425262728293031
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = commentParser;
  6. function commentParser(input) {
  7. const tokens = [];
  8. const length = input.length;
  9. let pos = 0;
  10. let next;
  11. while (pos < length) {
  12. next = input.indexOf('/*', pos);
  13. if (~next) {
  14. tokens.push([0, pos, next]);
  15. pos = next;
  16. next = input.indexOf('*/', pos + 2);
  17. tokens.push([1, pos + 2, next]);
  18. pos = next + 2;
  19. } else {
  20. tokens.push([0, pos, length]);
  21. pos = length;
  22. }
  23. }
  24. return tokens;
  25. };
  26. module.exports = exports['default'];