Reduced variable scopes

feature-extract-files
sevzero 2018-05-24 13:17:46 +00:00
parent 53bf52c989
commit 83c145c2ac
1 changed files with 6 additions and 6 deletions

View File

@ -31,18 +31,18 @@ class DechunkHTTP extends Operation {
* @returns {string}
*/
run(input, args) {
var chunks = [];
var chunkSizeEnd = input.indexOf("\n") + 1;
var lineEndings = input.charAt(chunkSizeEnd - 2) == "\r" ? "\r\n" : "\n";
var lineEndingsLength = lineEndings.length;
var chunkSize = parseInt(input.slice(0, chunkSizeEnd), 16);
let chunks = [];
let chunkSizeEnd = input.indexOf("\n") + 1;
let lineEndings = input.charAt(chunkSizeEnd - 2) === "\r" ? "\r\n" : "\n";
let lineEndingsLength = lineEndings.length;
let chunkSize = parseInt(input.slice(0, chunkSizeEnd), 16);
while (!isNaN(chunkSize)) {
chunks.push(input.slice(chunkSizeEnd, chunkSize + chunkSizeEnd));
input = input.slice(chunkSizeEnd + chunkSize + lineEndingsLength);
chunkSizeEnd = input.indexOf(lineEndings) + lineEndingsLength;
chunkSize = parseInt(input.slice(0, chunkSizeEnd), 16);
}
return chunks.join('') + input;
return chunks.join("") + input;
}
}