tasks/things/formatter.js
function simplified(js) {
	var is = false;
	var go = false;
	var here = 'out.html += '; // hardcoced
	var gone = '            '; // hardcoded to equal length
	var fixes = [];
	var lines = js.split('\n').map(function(line, index) {
		go = line.trim().startsWith(here);
		if (is && go) {
			line = line.replace(here, gone);
			fixes.push(index - 1);
		}
		is = go;
		return line;
	});
	fixes.forEach(function(index) {
		if (index > -1) {
			var line = lines[index];
			lines[index] = line.replace(/;$/, ' +');
		}
	});
	return lines.join('\n');
}
function simplified(js) {
	var is = false;
	var go = false;
	var here = 'out.html += '; // hardcoced
	var gone = '            '; // hardcoded to equal length
	var fixes = [];
	var lines = js.split('\n').map(function(line, index) {
		go = line.trim().startsWith(here);
		if (is && go) {
			line = line.replace(here, gone);
			fixes.push(index - 1);
		}
		is = go;
		return line;
	});
	fixes.forEach(function(index) {
		if (index > -1) {
			var line = lines[index];
			lines[index] = line.replace(/;$/, ' +');
		}
	});
	return lines.join('\n');
}
function simplified ( js ) { var is = false ; var go = false ; var here = 'out.html += ' ; // hardcoced var gone = '            ' ; // hardcoded to equal length var fixes = [ ] ; var lines = js . split ( '\n' ) . map ( function ( line , index ) { go = line . trim ( ) . startsWith ( here ) ; if ( is && go ) { line = line . replace ( here , gone ) ; fixes . push ( index - 1 ) ; } is = go ; return line ; } ) ; fixes . forEach ( function ( index ) { if ( index > - 1 ) { var line = lines [ index ] ; lines [ index ] = line . replace ( / ;$ / , ' +' ) ; } } ) ; return lines . join ( '\n' ) ; }
Substiture repeated lines of `out.html +=` with simple
`+` concatenation. Watch out for hardcoded strings here.
@param {string} js
@returns {string}
Substiture repeated lines of out . html + = with simple + concatenation . Watch out for hardcoded strings here .