Skip to content

Commit 8d9080a

Browse files
Raoul Jaeckeltargos
authored andcommitted
querystring: replace var with let/const
PR-URL: #30429 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 34b136b commit 8d9080a

1 file changed

Lines changed: 31 additions & 31 deletions

File tree

‎lib/querystring.js‎

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ const unhexTable = [
6767
// A safe fast alternative to decodeURIComponent
6868
functionunescapeBuffer(s,decodeSpaces){
6969
constout=Buffer.allocUnsafe(s.length);
70-
varindex=0;
71-
varoutIndex=0;
72-
varcurrentChar;
73-
varnextChar;
74-
varhexHigh;
75-
varhexLow;
70+
letindex=0;
71+
letoutIndex=0;
72+
letcurrentChar;
73+
letnextChar;
74+
lethexHigh;
75+
lethexLow;
7676
constmaxLength=s.length-2;
7777
// Flag to know if some hex chars have been decoded
78-
varhasHex=false;
78+
lethasHex=false;
7979
while(index<s.length){
8080
currentChar=s.charCodeAt(index);
8181
if(currentChar===43/* '+' */&&decodeSpaces){
@@ -161,27 +161,27 @@ function stringify(obj, sep, eq, options) {
161161
sep=sep||'&';
162162
eq=eq||'=';
163163

164-
varencode=QueryString.escape;
164+
letencode=QueryString.escape;
165165
if(options&&typeofoptions.encodeURIComponent==='function'){
166166
encode=options.encodeURIComponent;
167167
}
168168

169169
if(obj!==null&&typeofobj==='object'){
170-
varkeys=Object.keys(obj);
171-
varlen=keys.length;
172-
varflast=len-1;
173-
varfields='';
174-
for(vari=0;i<len;++i){
175-
vark=keys[i];
176-
varv=obj[k];
177-
varks=encode(stringifyPrimitive(k));
170+
constkeys=Object.keys(obj);
171+
constlen=keys.length;
172+
constflast=len-1;
173+
letfields='';
174+
for(leti=0;i<len;++i){
175+
constk=keys[i];
176+
constv=obj[k];
177+
letks=encode(stringifyPrimitive(k));
178178
ks+=eq;
179179

180180
if(Array.isArray(v)){
181-
varvlen=v.length;
181+
constvlen=v.length;
182182
if(vlen===0)continue;
183-
varvlast=vlen-1;
184-
for(varj=0;j<vlen;++j){
183+
constvlast=vlen-1;
184+
for(letj=0;j<vlen;++j){
185185
fields+=ks;
186186
fields+=encode(stringifyPrimitive(v[j]));
187187
if(j<vlast)
@@ -204,7 +204,7 @@ function charCodes(str) {
204204
if(str.length===0)return[];
205205
if(str.length===1)return[str.charCodeAt(0)];
206206
constret=newArray(str.length);
207-
for(vari=0;i<str.length;++i)
207+
for(leti=0;i<str.length;++i)
208208
ret[i]=str.charCodeAt(i);
209209
returnret;
210210
}
@@ -244,7 +244,7 @@ function parse(qs, sep, eq, options) {
244244
constsepLen=sepCodes.length;
245245
consteqLen=eqCodes.length;
246246

247-
varpairs=1000;
247+
letpairs=1000;
248248
if(options&&typeofoptions.maxKeys==='number'){
249249
// -1 is used in place of a value like Infinity for meaning
250250
// "unlimited pairs" because of additional checks V8 (at least as of v5.4)
@@ -255,22 +255,22 @@ function parse(qs, sep, eq, options) {
255255
pairs=(options.maxKeys>0 ? options.maxKeys : -1);
256256
}
257257

258-
vardecode=QueryString.unescape;
258+
letdecode=QueryString.unescape;
259259
if(options&&typeofoptions.decodeURIComponent==='function'){
260260
decode=options.decodeURIComponent;
261261
}
262262
constcustomDecode=(decode!==qsUnescape);
263263

264-
varlastPos=0;
265-
varsepIdx=0;
266-
vareqIdx=0;
267-
varkey='';
268-
varvalue='';
269-
varkeyEncoded=customDecode;
270-
varvalEncoded=customDecode;
264+
letlastPos=0;
265+
letsepIdx=0;
266+
leteqIdx=0;
267+
letkey='';
268+
letvalue='';
269+
letkeyEncoded=customDecode;
270+
letvalEncoded=customDecode;
271271
constplusChar=(customDecode ? '%20' : ' ');
272-
varencodeCheck=0;
273-
for(vari=0;i<qs.length;++i){
272+
letencodeCheck=0;
273+
for(leti=0;i<qs.length;++i){
274274
constcode=qs.charCodeAt(i);
275275

276276
// Try matching key/value pair separator (e.g. '&')

0 commit comments

Comments
 (0)