Comparing version 0.7.4 to 0.7.5
@@ -9,3 +9,3 @@ 'use strict'; | ||
if (typeof code !== 'string') { | ||
throw new TypeError("Input code/text/html must be string."); | ||
throw new TypeError("Input code/text/html must be a string."); | ||
} | ||
@@ -25,3 +25,2 @@ | ||
optTrim = options && options.trim, // 'trim' option; | ||
checkRegEx = false, // indicates whether regEx is to be used; | ||
isHtml, // set when the input is recognized as HTML; | ||
@@ -38,3 +37,2 @@ regEx; // regular expression details; | ||
regEx = utils.parseRegEx(code); | ||
checkRegEx = regEx.length > 0; | ||
} | ||
@@ -48,3 +46,3 @@ } else { | ||
if (code[idx + 1] === '/') { | ||
if (checkRegEx && utils.indexInRegEx(idx, regEx)) { | ||
if (inRegEx()) { | ||
s += '/'; | ||
@@ -71,3 +69,3 @@ continue; | ||
if (code[idx + 1] === '*') { | ||
if (checkRegEx && utils.indexInRegEx(idx, regEx)) { | ||
if (inRegEx()) { | ||
s += '/'; | ||
@@ -190,3 +188,3 @@ continue; | ||
if (!isHtml && (symbol === '\'' || symbol === '"' || symbol === '`') && (!idx || code[idx - 1] !== '\\')) { | ||
if (checkRegEx && utils.indexInRegEx(idx, regEx)) { | ||
if (inRegEx()) { | ||
continue; | ||
@@ -214,2 +212,8 @@ } | ||
function inRegEx() { | ||
if (regEx && regEx.length) { | ||
return utils.indexInRegEx(idx, regEx); | ||
} | ||
} | ||
function trim() { | ||
@@ -216,0 +220,0 @@ if (optTrim) { |
@@ -58,2 +58,5 @@ 'use strict'; | ||
//////////////////////////////////////////////// | ||
// Returns space symbol multiplied n times. | ||
// | ||
// istanbul ignore next | ||
@@ -60,0 +63,0 @@ // we are not generating test coverage for this |
{ | ||
"name": "decomment", | ||
"version": "0.7.4", | ||
"version": "0.7.5", | ||
"description": "Removes comments from JSON, JavaScript, CSS, HTML, etc.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -36,2 +36,4 @@ decomment | ||
For build systems / task runners see [gulp-decomment] and [grunt-decomment]. | ||
## Features | ||
@@ -147,1 +149,3 @@ | ||
[esprima]:https://github.com/jquery/esprima | ||
[grunt-decomment]:https://github.com/vitaly-t/grunt-decomment | ||
[gulp-decomment]:https://github.com/vitaly-t/gulp-decomment |
@@ -7,3 +7,3 @@ 'use strict'; | ||
describe("Single:", function () { | ||
describe("Entry:", function () { | ||
@@ -14,3 +14,3 @@ describe("non-string input", function () { | ||
decomment(); | ||
}).toThrow(new TypeError("Input code/text/html must be string.")); | ||
}).toThrow(new TypeError("Input code/text/html must be a string.")); | ||
}); | ||
@@ -17,0 +17,0 @@ }); |
43337
883
150