You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
674 B

4 years ago
  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'];