Skip to content

Commit b426391

Browse files
committed
refactor: improve readability of parse
1 parent 753715b commit b426391

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/parse.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ function parse(input) {
1313
return result;
1414
}
1515

16+
const inputLength = input.length;
1617
let key = "";
1718
let value = "";
1819
let startingIndex = -1;
1920
let equalityIndex = -1;
2021
let shouldDecode = false;
2122
let hasPlus = false;
22-
const lastIndex = input.length;
2323

2424
// Have a boundary of input.length + 1 to access last pair inside the loop.
25-
for (let i = 0; i < lastIndex + 1; i++) {
26-
let c = (i !== lastIndex && input.charCodeAt(i)) || -1;
25+
for (let i = 0; i < inputLength + 1; i++) {
26+
let c = (i !== inputLength && input.charCodeAt(i)) || -1;
2727

2828
// Handle '&' and end of line to pass the current values to result
2929
if (c === 38 || c === -1) {

0 commit comments

Comments
 (0)