Skip to content

Commit c8bbdd3

Browse files
committed
remove newline insertions from loop protect code
1 parent 9977f57 commit c8bbdd3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

dist/loop-protect.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/loop-protect.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ if (typeof DEBUG === 'undefined') { DEBUG = true; } //jshint ignore:line
113113
labelRe.lastIndex = 0;
114114
var beforeLoop = false;
115115

116-
var theRest = lines.slice(lineNum).join('\n').substr(index).replace(labelRe, '');
116+
var theRest = lines.slice(lineNum).substr(index).replace(labelRe, '');
117117
theRest.replace(reSingle, function commentStripper(match, capture, i) {
118118
var target = theRest.substr(0, i).replace(comments, '').trim();
119119
DEBUG && debug('- directlyBeforeLoop: ' + target); // jshint ignore:line
@@ -292,17 +292,17 @@ if (typeof DEBUG === 'undefined') { DEBUG = true; } //jshint ignore:line
292292
if (lineNum !== originalLineNum) {
293293
DEBUG && debug('- multiline inline loop'); // jshint ignore:line
294294
// affect the compiled line
295-
recompiled[originalLineNum] = recompiled[originalLineNum].substring(0, terminator + 1) + '{\nif (' + method + '({ line: ' + printLineNumber + ' })) break;\n' + recompiled[originalLineNum].substring(terminator + 1);
296-
line += '\n}}\n';
295+
recompiled[originalLineNum] = recompiled[originalLineNum].substring(0, terminator + 1) + '{if (' + method + '({ line: ' + printLineNumber + ' })) break;' + recompiled[originalLineNum].substring(terminator + 1);
296+
line += '}}';
297297
} else {
298298
// simpler
299299
DEBUG && debug('- single line inline loop'); // jshint ignore:line
300-
line = line.substring(0, terminator + 1) + '{\nif (' + method + '({ line: ' + printLineNumber + ' })) break;\n' + line.substring(terminator + 1) + '\n}}\n';
300+
line = line.substring(0, terminator + 1) + '{if (' + method + '({ line: ' + printLineNumber + ' })) break;' + line.substring(terminator + 1) + '}}';
301301
}
302302
foundLoopEnd = true;
303303
} else if (character === '{') {
304304
DEBUG && debug('- multiline with braces'); // jshint ignore:line
305-
var insert = ';\nif (' + method + '({ line: ' + printLineNumber + ' })) break;\n';
305+
var insert = ';if (' + method + '({ line: ' + printLineNumber + ' })) break;';
306306
line = line.substring(0, index + 1) + insert + line.substring(index + 1);
307307

308308
index += insert.length;

0 commit comments

Comments
 (0)