postcss-discard-comments
Advanced tools
Comparing version 4.0.0-rc.0 to 4.0.0-rc.2
@@ -7,2 +7,4 @@ 'use strict'; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _postcss = require('postcss'); | ||
@@ -27,4 +29,7 @@ | ||
function matchesComments(source) { | ||
return (0, _commentParser2.default)(source).filter(function (node) { | ||
return node.type === 'comment'; | ||
return (0, _commentParser2.default)(source).filter(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 1), | ||
type = _ref2[0]; | ||
return type; | ||
}); | ||
@@ -36,10 +41,16 @@ } | ||
var parsed = (0, _commentParser2.default)(source).reduce(function (value, node) { | ||
if (node.type !== 'comment') { | ||
return value + node.value; | ||
var parsed = (0, _commentParser2.default)(source).reduce(function (value, _ref3) { | ||
var _ref4 = _slicedToArray(_ref3, 3), | ||
type = _ref4[0], | ||
start = _ref4[1], | ||
end = _ref4[2]; | ||
var contents = source.slice(start, end); | ||
if (!type) { | ||
return value + contents; | ||
} | ||
if (remover.canRemove(node.value)) { | ||
if (remover.canRemove(contents)) { | ||
return value + separator; | ||
} | ||
return value + '/*' + node.value + '*/'; | ||
return `${value}/*${contents}*/`; | ||
}, ''); | ||
@@ -46,0 +57,0 @@ |
@@ -17,19 +17,10 @@ 'use strict'; | ||
if (~next) { | ||
tokens.push({ | ||
type: 'other', | ||
value: input.slice(pos, next) | ||
}); | ||
tokens.push([0, pos, next]); | ||
pos = next; | ||
next = input.indexOf('*/', pos + 2); | ||
tokens.push({ | ||
type: 'comment', | ||
value: input.slice(pos + 2, next) | ||
}); | ||
tokens.push([1, pos + 2, next]); | ||
pos = next + 2; | ||
} else { | ||
tokens.push({ | ||
type: 'other', | ||
value: input.slice(pos) | ||
}); | ||
tokens.push([0, pos, length]); | ||
pos = length; | ||
@@ -36,0 +27,0 @@ } |
{ | ||
"name": "postcss-discard-comments", | ||
"version": "4.0.0-rc.0", | ||
"version": "4.0.0-rc.2", | ||
"description": "Discard comments in your CSS files with PostCSS.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11960
137