commentRemover.js 735 B

1234567891011121314151617181920212223242526272829303132
  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'];