commentRemover.js 746 B

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