htmljs-parser
Advanced tools
Comparing version 2.2.4 to 2.2.5
@@ -18,3 +18,2 @@ var operators = exports.operators = [ | ||
'in', | ||
'new', | ||
// 'from', -- as in <import x from './file'/> | ||
@@ -39,2 +38,8 @@ // 'typeof', -- would need to look behind, not ahead | ||
var unary = [ | ||
'typeof', | ||
'new', | ||
'void' | ||
]; | ||
// Look for longest operators first | ||
@@ -45,11 +50,10 @@ operators.sort(function(a, b) { | ||
var requiresWhitespace = exports.requiresWhitespace = { | ||
'instanceof':true, | ||
'in':true, | ||
'typeof':true | ||
}; | ||
exports.longest = operators.sort((a, b) => b.length-a.length)[0].length+1; | ||
exports.patternNext = new RegExp('^\\s*('+operators.map(escapeOperator).join('|')+')\\s*(?!-)'); | ||
exports.patternPrev = new RegExp('[^-+](?:'+operators.concat(unary).map(escapeOperator).join('|')+')(\\s*)$'); | ||
var escapedOperators = operators.map(o => { | ||
if(requiresWhitespace[o]) { | ||
return '\\s'+escapeNonAlphaNumeric(o)+'\\s'; | ||
function escapeOperator(o) { | ||
if(/^[A-Z]+$/i.test(o)) { | ||
return '\\b'+escapeNonAlphaNumeric(o)+'\\b'; | ||
} | ||
@@ -60,10 +64,6 @@ if(o === '/') { | ||
return escapeNonAlphaNumeric(o); | ||
}); | ||
} | ||
exports.longest = operators.sort((a, b) => b.length-a.length)[0].length+1; | ||
exports.patternNext = new RegExp('^\\s*('+escapedOperators.join('|')+')\\s*(?!-)'); | ||
exports.patternPrev = new RegExp('[^-+](?:'+escapedOperators.join('|')+')(\\s*)$'); | ||
function escapeNonAlphaNumeric(str) { | ||
return str.replace(/([^\w\d])/g, '\\$1'); | ||
} |
@@ -41,3 +41,3 @@ { | ||
}, | ||
"version": "2.2.4" | ||
"version": "2.2.5" | ||
} |
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
239780
926
3620