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.

31 lines
735 B

4 years ago
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. function CommentRemover(options) {
  6. this.options = options;
  7. }
  8. CommentRemover.prototype.canRemove = function (comment) {
  9. const remove = this.options.remove;
  10. if (remove) {
  11. return remove(comment);
  12. } else {
  13. const isImportant = comment.indexOf('!') === 0;
  14. if (!isImportant) {
  15. return true;
  16. }
  17. if (this.options.removeAll || this._hasFirst) {
  18. return true;
  19. } else if (this.options.removeAllButFirst && !this._hasFirst) {
  20. this._hasFirst = true;
  21. return false;
  22. }
  23. }
  24. };
  25. exports.default = CommentRemover;
  26. module.exports = exports['default'];