Strip-Whitespace will remove extraneous spaces from strings. It's perfect for working with rendering templates (ex. mustache, handlebars) or es6 javascript templates. It works with anything where you might create very long strings.
function() {
if (condition) {
const longString = ' String with some extra spaces ';
}
}
function() {
if (condition) {
const longString = ' String with some extra spaces ';
}
}
$ strip-whitespace --input <input-file> --output <output-file>
var StripWhitespace = require('strip-whitespace');
// options are optional and can be omitted
var stripWhitespace = new StripWhitespace(options);
var result = stripWhitespace.strip(code);
// do things with the code
code = result.code;
All options are optional
{
shouldStripWhitespace: function(fatString) {
// following code will answer the question: should this string be stripped of whitespace?
if (fatString.startsWith('DO NOT MODIFY THIS STRING')) {
return false;
}
return true;
}
}