@@ -13,10 +13,7 @@ const {
13
13
IteratorPrototype,
14
14
Number,
15
15
ObjectDefineProperties,
16
- ObjectDefineProperty,
17
- ObjectGetOwnPropertySymbols,
18
- ObjectGetPrototypeOf,
19
- ObjectKeys,
16
+ ObjectSetPrototypeOf,
20
17
ReflectGetOwnPropertyDescriptor,
21
18
ReflectOwnKeys,
22
19
RegExpPrototypeSymbolReplace,
@@ -90,8 +87,7 @@ const bindingUrl = internalBinding('url');
90
87
91
88
const FORWARD_SLASH = / \/ / g;
92
89
93
- const context = Symbol ( 'context' ) ;
94
- const searchParams = Symbol ( 'query' ) ;
90
+ const contextForInspect = Symbol ( 'context' ) ;
95
91
96
92
const updateActions = {
97
93
kProtocol : 0 ,
@@ -172,15 +168,124 @@ class URLContext {
172
168
}
173
169
}
174
170
175
- function isURLSearchParams ( self ) {
176
- return self && self [ searchParams ] && ! self [ searchParams ] [ searchParams ] ;
171
+ let setURLSearchParamsContext ;
172
+ let getURLSearchParamsList ;
173
+ let setURLSearchParams ;
174
+
175
+ class URLSearchParamsIterator {
176
+ #target;
177
+ #kind;
178
+ #index;
179
+
180
+ // https://heycam.github.io/webidl/#dfn-default-iterator-object
181
+ constructor ( target , kind ) {
182
+ this . #target = target ;
183
+ this . #kind = kind ;
184
+ this . #index = 0 ;
185
+ }
186
+
187
+ next ( ) {
188
+ if ( typeof this !== 'object' || this === null || ! ( #target in this ) )
189
+ throw new ERR_INVALID_THIS ( 'URLSearchParamsIterator' ) ;
190
+
191
+ const index = this . #index;
192
+ const values = getURLSearchParamsList ( this . #target) ;
193
+ const len = values . length ;
194
+ if ( index >= len ) {
195
+ return {
196
+ value : undefined ,
197
+ done : true ,
198
+ } ;
199
+ }
200
+
201
+ const name = values [ index ] ;
202
+ const value = values [ index + 1 ] ;
203
+ this . #index = index + 2 ;
204
+
205
+ let result ;
206
+ if ( this . #kind === 'key' ) {
207
+ result = name ;
208
+ } else if ( this . #kind === 'value' ) {
209
+ result = value ;
210
+ } else {
211
+ result = [ name , value ] ;
212
+ }
213
+
214
+ return {
215
+ value : result ,
216
+ done : false ,
217
+ } ;
218
+ }
219
+
220
+ [ inspect . custom ] ( recurseTimes , ctx ) {
221
+ if ( ! this || typeof this !== 'object' || ! ( #target in this ) )
222
+ throw new ERR_INVALID_THIS ( 'URLSearchParamsIterator' ) ;
223
+
224
+ if ( typeof recurseTimes === 'number' && recurseTimes < 0 )
225
+ return ctx . stylize ( '[Object]' , 'special' ) ;
226
+
227
+ const innerOpts = { ...ctx } ;
228
+ if ( recurseTimes !== null ) {
229
+ innerOpts . depth = recurseTimes - 1 ;
230
+ }
231
+ const index = this . #index;
232
+ const values = getURLSearchParamsList ( this . #target) ;
233
+ const output = ArrayPrototypeReduce (
234
+ ArrayPrototypeSlice ( values , index ) ,
235
+ ( prev , cur , i ) => {
236
+ const key = i % 2 === 0 ;
237
+ if ( this . #kind === 'key' && key ) {
238
+ ArrayPrototypePush ( prev , cur ) ;
239
+ } else if ( this . #kind === 'value' && ! key ) {
240
+ ArrayPrototypePush ( prev , cur ) ;
241
+ } else if ( this . #kind === 'key+value' && ! key ) {
242
+ ArrayPrototypePush ( prev , [ values [ index + i - 1 ] , cur ] ) ;
243
+ }
244
+ return prev ;
245
+ } ,
246
+ [ ] ,
247
+ ) ;
248
+ const breakLn = StringPrototypeIncludes ( inspect ( output , innerOpts ) , '\n' ) ;
249
+ const outputStrs = ArrayPrototypeMap ( output , ( p ) => inspect ( p , innerOpts ) ) ;
250
+ let outputStr ;
251
+ if ( breakLn ) {
252
+ outputStr = `\n ${ ArrayPrototypeJoin ( outputStrs , ',\n ' ) } ` ;
253
+ } else {
254
+ outputStr = ` ${ ArrayPrototypeJoin ( outputStrs , ', ' ) } ` ;
255
+ }
256
+ return `${ this [ SymbolToStringTag ] } {${ outputStr } }` ;
257
+ }
177
258
}
178
259
260
+ // https://heycam.github.io/webidl/#dfn-iterator-prototype-object
261
+ delete URLSearchParamsIterator . prototype . constructor ;
262
+ ObjectSetPrototypeOf ( URLSearchParamsIterator . prototype , IteratorPrototype ) ;
263
+
264
+ ObjectDefineProperties ( URLSearchParamsIterator . prototype , {
265
+ [ SymbolToStringTag ] : { __proto__ : null , configurable : true , value : 'URLSearchParams Iterator' } ,
266
+ next : kEnumerableProperty ,
267
+ } ) ;
268
+
269
+
179
270
class URLSearchParams {
180
- [ searchParams ] = [ ] ;
271
+ # searchParams = [ ] ;
181
272
182
273
// "associated url object"
183
- [ context ] = null ;
274
+ #context;
275
+
276
+ static {
277
+ setURLSearchParamsContext = ( obj , ctx ) => {
278
+ obj . #context = ctx ;
279
+ } ;
280
+ getURLSearchParamsList = ( obj ) => obj . #searchParams;
281
+ setURLSearchParams = ( obj , query ) => {
282
+ if ( query === undefined ) {
283
+ obj . #searchParams = [ ] ;
284
+ } else {
285
+ obj . #searchParams = parseParams ( query ) ;
286
+ }
287
+ } ;
288
+ }
184
289
185
290
// URL Standard says the default value is '', but as undefined and '' have
186
291
// the same result, undefined is used to prevent unnecessary parsing.
@@ -191,11 +296,11 @@ class URLSearchParams {
191
296
// Do nothing
192
297
} else if ( typeof init === 'object' || typeof init === 'function' ) {
193
298
const method = init [ SymbolIterator ] ;
194
- if ( method === this [ SymbolIterator ] ) {
299
+ if ( method === this [ SymbolIterator ] && #searchParams in init ) {
195
300
// While the spec does not have this branch, we can use it as a
196
301
// shortcut to avoid having to go through the costly generic iterator.
197
- const childParams = init [ searchParams ] ;
198
- this [ searchParams ] = childParams . slice ( ) ;
302
+ const childParams = init . # searchParams;
303
+ this . # searchParams = childParams . slice ( ) ;
199
304
} else if ( method != null ) {
200
305
// Sequence<sequence<USVString>>
201
306
if ( typeof method !== 'function' ) {
@@ -221,7 +326,7 @@ class URLSearchParams {
221
326
throw new ERR_INVALID_TUPLE ( 'Each query pair' , '[name, value]' ) ;
222
327
}
223
328
// Append (innerSequence[0], innerSequence[1]) to querys list.
224
- ArrayPrototypePush ( this [ searchParams ] , toUSVString ( pair [ 0 ] ) , toUSVString ( pair [ 1 ] ) ) ;
329
+ ArrayPrototypePush ( this . # searchParams, toUSVString ( pair [ 0 ] ) , toUSVString ( pair [ 1 ] ) ) ;
225
330
} else {
226
331
if ( ( ( typeof pair !== 'object' && typeof pair !== 'function' ) ||
227
332
typeof pair [ SymbolIterator ] !== 'function' ) ) {
@@ -232,7 +337,7 @@ class URLSearchParams {
232
337
233
338
for ( const element of pair ) {
234
339
length ++ ;
235
- ArrayPrototypePush ( this [ searchParams ] , toUSVString ( element ) ) ;
340
+ ArrayPrototypePush ( this . # searchParams, toUSVString ( element ) ) ;
236
341
}
237
342
238
343
// If innerSequence's size is not 2, then throw a TypeError.
@@ -257,9 +362,9 @@ class URLSearchParams {
257
362
// In that case, we retain the later one. Refer to WPT.
258
363
const keyIdx = visited . get ( typedKey ) ;
259
364
if ( keyIdx !== undefined ) {
260
- this [ searchParams ] [ keyIdx ] = typedValue ;
365
+ this . # searchParams[ keyIdx ] = typedValue ;
261
366
} else {
262
- visited . set ( typedKey , ArrayPrototypePush ( this [ searchParams ] ,
367
+ visited . set ( typedKey , ArrayPrototypePush ( this . # searchParams,
263
368
typedKey ,
264
369
typedValue ) - 1 ) ;
265
370
}
@@ -269,12 +374,12 @@ class URLSearchParams {
269
374
} else {
270
375
// https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
271
376
init = toUSVString ( init ) ;
272
- this [ searchParams ] = init ? parseParams ( init ) : [ ] ;
377
+ this . # searchParams = init ? parseParams ( init ) : [ ] ;
273
378
}
274
379
}
275
380
276
381
[ inspect . custom ] ( recurseTimes , ctx ) {
277
- if ( ! isURLSearchParams ( this ) )
382
+ if ( typeof this !== 'object' || this === null || ! ( #searchParams in this ) )
278
383
throw new ERR_INVALID_THIS ( 'URLSearchParams' ) ;
279
384
280
385
if ( typeof recurseTimes === 'number' && recurseTimes < 0 )
@@ -287,7 +392,7 @@ class URLSearchParams {
287
392
}
288
393
const innerInspect = ( v ) => inspect ( v , innerOpts ) ;
289
394
290
- const list = this [ searchParams ] ;
395
+ const list = this . # searchParams;
291
396
const output = [ ] ;
292
397
for ( let i = 0 ; i < list . length ; i += 2 )
293
398
ArrayPrototypePush (
@@ -310,13 +415,13 @@ class URLSearchParams {
310
415
}
311
416
312
417
get size ( ) {
313
- if ( ! isURLSearchParams ( this ) )
418
+ if ( typeof this !== 'object' || this === null || ! ( #searchParams in this ) )
314
419
throw new ERR_INVALID_THIS ( 'URLSearchParams' ) ;
315
- return this [ searchParams ] . length / 2 ;
420
+ return this . # searchParams. length / 2 ;
316
421
}
317
422
318
423
append ( name , value ) {
319
- if ( ! isURLSearchParams ( this ) )
424
+ if ( typeof this !== 'object' || this === null || ! ( #searchParams in this ) )
320
425
throw new ERR_INVALID_THIS ( 'URLSearchParams' ) ;
321
426
322
427
if ( arguments . length < 2 ) {
@@ -325,21 +430,21 @@ class URLSearchParams {
325
430
326
431
name = toUSVString ( name ) ;
327
432
value = toUSVString ( value ) ;
328
- ArrayPrototypePush ( this [ searchParams ] , name , value ) ;
329
- if ( this [ context ] ) {
330
- this [ context ] . search = this . toString ( ) ;
433
+ ArrayPrototypePush ( this . # searchParams, name , value ) ;
434
+ if ( this . # context) {
435
+ this . # context. search = this . toString ( ) ;
331
436
}
332
437
}
333
438
334
439
delete ( name ) {
335
- if ( ! isURLSearchParams ( this ) )
440
+ if ( typeof this !== 'object' || this === null || ! ( #searchParams in this ) )
336
441
throw new ERR_INVALID_THIS ( 'URLSearchParams' ) ;
337
442
338
443
if ( arguments . length < 1 ) {
339
444
throw new ERR_MISSING_ARGS ( 'name' ) ;
340
445
}
341
446
342
- const list = this [ searchParams ] ;
447
+ const list = this . # searchParams;
343
448
name = toUSVString ( name ) ;
344
449
for ( let i = 0 ; i < list . length ; ) {
345
450
const cur = list [ i ] ;
@@ -349,20 +454,20 @@ class URLSearchParams {
349
454
i += 2 ;
350
455
}
351
456
}
352
- if ( this [ context ] ) {
353
- this [ context ] . search = this . toString ( ) ;
457
+ if ( this . # context) {
458
+ this . # context. search = this . toString ( ) ;
354
459
}
355
460
}
356
461
357
462
get ( name ) {
358
- if ( ! isURLSearchParams ( this ) )
463
+ if ( typeof this !== 'object' || this === null || ! ( #searchParams in this ) )
359
464
throw new ERR_INVALID_THIS ( 'URLSearchParams' ) ;
360
465
361
466
if ( arguments . length < 1 ) {
362
467
throw new ERR_MISSING_ARGS ( 'name' ) ;
363
468
}
364
469
365
- const list = this [ searchParams ] ;
470
+ const list = this . # searchParams;
366
471
name = toUSVString ( name ) ;
367
472
for ( let i = 0 ; i < list . length ; i += 2 ) {
368
473
if ( list [ i ] === name ) {
@@ -373,14 +478,14 @@ class URLSearchParams {
373
478
}
374
479
375
480
getAll ( name ) {
376
- if ( ! isURLSearchParams ( this ) )
481
+ if ( typeof this !== 'object' || this === null || ! ( #searchParams in this ) )
377
482
throw new ERR_INVALID_THIS ( 'URLSearchParams' ) ;
378
483
379
484
if ( arguments . length < 1 ) {
380
485
throw new ERR_MISSING_ARGS ( 'name' ) ;
381
486
}
382
487
383
- const list = this [ searchParams ] ;
488
+ const list = this . # searchParams;
384
489
const values = [ ] ;
385
490
name = toUSVString ( name ) ;
386
491
for ( let i = 0 ; i < list . length ; i += 2 ) {
@@ -392,14 +497,14 @@ class URLSearchParams {
392
497
}
393
498
394
499
has ( name ) {
395
- if ( ! isURLSearchParams ( this ) )
500
+ if ( typeof this !== 'object' || this === null || ! ( #searchParams in this ) )
396
501
throw new ERR_INVALID_THIS ( 'URLSearchParams' ) ;
397
502
398
503
if ( arguments . length < 1 ) {
399
504
throw new ERR_MISSING_ARGS ( 'name' ) ;
400
505
}
401
506
402
- const list = this [ searchParams ] ;
507
+ const list = this . # searchParams;
403
508
name = toUSVString ( name ) ;
404
509
for ( let i = 0 ; i < list . length ; i += 2 ) {
405
510
if ( list [ i ] === name ) {
@@ -410,14 +515,14 @@ class URLSearchParams {
410
515
}
411
516
412
517
set ( name , value ) {
413
- if ( ! isURLSearchParams ( this ) )
518
+ if ( typeof this !== 'object' || this === null || ! ( #searchParams in this ) )
414
519
throw new ERR_INVALID_THIS ( 'URLSearchParams' ) ;
415
520
416
521
if ( arguments . length < 2 ) {
417
522
throw new ERR_MISSING_ARGS ( 'name' , 'value' ) ;
418
523
}
419
524
420
- const list = this [ searchParams ] ;
525
+ const list = this . # searchParams;
421
526
name = toUSVString ( name ) ;
422
527
value = toUSVString ( value ) ;
423
528
@@ -446,13 +551,16 @@ class URLSearchParams {
446
551
ArrayPrototypePush ( list , name , value ) ;
447
552
}
448
553
449
- if ( this [ context ] ) {
450
- this [ context ] . search = this . toString ( ) ;
554
+ if ( this . # context) {
555
+ this . # context. search = this . toString ( ) ;
451
556
}
452
557
}
453
558
454
559
sort ( ) {
455
- const a = this [ searchParams ] ;
560
+ if ( typeof this !== 'object' || this === null || ! ( #searchParams in this ) )
561
+ throw new ERR_INVALID_THIS ( 'URLSearchParams' ) ;
562
+
563
+ const a = this . #searchParams;
456
564
const len = a . length ;
457
565
458
566
if ( len <= 2 ) {
@@ -492,62 +600,62 @@ class URLSearchParams {
492
600
}
493
601
}
494
602
495
- if ( this [ context ] ) {
496
- this [ context ] . search = this . toString ( ) ;
603
+ if ( this . # context) {
604
+ this . # context. search = this . toString ( ) ;
497
605
}
498
606
}
499
607
500
608
// https://heycam.github.io/webidl/#es-iterators
501
609
// Define entries here rather than [Symbol.iterator] as the function name
502
610
// must be set to `entries`.
503
611
entries ( ) {
504
- if ( ! isURLSearchParams ( this ) )
612
+ if ( typeof this !== 'object' || this === null || ! ( #searchParams in this ) )
505
613
throw new ERR_INVALID_THIS ( 'URLSearchParams' ) ;
506
614
507
- return createSearchParamsIterator ( this , 'key+value' ) ;
615
+ return new URLSearchParamsIterator ( this , 'key+value' ) ;
508
616
}
509
617
510
618
forEach ( callback , thisArg = undefined ) {
511
- if ( ! isURLSearchParams ( this ) )
619
+ if ( typeof this !== 'object' || this === null || ! ( #searchParams in this ) )
512
620
throw new ERR_INVALID_THIS ( 'URLSearchParams' ) ;
513
621
514
622
validateFunction ( callback , 'callback' ) ;
515
623
516
- let list = this [ searchParams ] ;
624
+ let list = this . # searchParams;
517
625
518
626
let i = 0 ;
519
627
while ( i < list . length ) {
520
628
const key = list [ i ] ;
521
629
const value = list [ i + 1 ] ;
522
630
callback . call ( thisArg , value , key , this ) ;
523
631
// In case the URL object's `search` is updated
524
- list = this [ searchParams ] ;
632
+ list = this . # searchParams;
525
633
i += 2 ;
526
634
}
527
635
}
528
636
529
637
// https://heycam.github.io/webidl/#es-iterable
530
638
keys ( ) {
531
- if ( ! isURLSearchParams ( this ) )
639
+ if ( typeof this !== 'object' || this === null || ! ( #searchParams in this ) )
532
640
throw new ERR_INVALID_THIS ( 'URLSearchParams' ) ;
533
641
534
- return createSearchParamsIterator ( this , 'key' ) ;
642
+ return new URLSearchParamsIterator ( this , 'key' ) ;
535
643
}
536
644
537
645
values ( ) {
538
- if ( ! isURLSearchParams ( this ) )
646
+ if ( typeof this !== 'object' || this === null || ! ( #searchParams in this ) )
539
647
throw new ERR_INVALID_THIS ( 'URLSearchParams' ) ;
540
648
541
- return createSearchParamsIterator ( this , 'value' ) ;
649
+ return new URLSearchParamsIterator ( this , 'value' ) ;
542
650
}
543
651
544
652
// https://heycam.github.io/webidl/#es-stringifier
545
653
// https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
546
654
toString ( ) {
547
- if ( ! isURLSearchParams ( this ) )
655
+ if ( typeof this !== 'object' || this === null || ! ( #searchParams in this ) )
548
656
throw new ERR_INVALID_THIS ( 'URLSearchParams' ) ;
549
657
550
- return serializeParams ( this [ searchParams ] ) ;
658
+ return serializeParams ( this . # searchParams) ;
551
659
}
552
660
}
553
661
@@ -635,7 +743,7 @@ class URL {
635
743
obj . hash = this . hash ;
636
744
637
745
if ( opts . showHidden ) {
638
- obj [ context ] = this . #context;
746
+ obj [ contextForInspect ] = this . #context;
639
747
}
640
748
641
749
return `${ constructor . name } ${ inspect ( obj , opts ) } ` ;
@@ -668,9 +776,9 @@ class URL {
668
776
669
777
if ( this . #searchParams) {
670
778
if ( this . #context. hasSearch ) {
671
- this . #searchParams[ searchParams ] = parseParams ( this . search ) ;
779
+ setURLSearchParams ( this . #searchParams, this . search ) ;
672
780
} else {
673
- this . #searchParams[ searchParams ] = [ ] ;
781
+ setURLSearchParams ( this . #searchParams, undefined ) ;
674
782
}
675
783
}
676
784
}
@@ -846,7 +954,7 @@ class URL {
846
954
// Create URLSearchParams on demand to greatly improve the URL performance.
847
955
if ( this . #searchParams == null ) {
848
956
this . #searchParams = new URLSearchParams ( this . search ) ;
849
- this . #searchParams[ context ] = this ;
957
+ setURLSearchParamsContext ( this . #searchParams, this ) ;
850
958
}
851
959
return this . #searchParams;
852
960
}
@@ -1099,38 +1207,6 @@ function serializeParams(array) {
1099
1207
return output ;
1100
1208
}
1101
1209
1102
- // Mainly to mitigate func-name-matching ESLint rule
1103
- function defineIDLClass ( proto , classStr , obj ) {
1104
- // https://heycam.github.io/webidl/#dfn-class-string
1105
- ObjectDefineProperty ( proto , SymbolToStringTag , {
1106
- __proto__ : null ,
1107
- writable : false ,
1108
- enumerable : false ,
1109
- configurable : true ,
1110
- value : classStr ,
1111
- } ) ;
1112
-
1113
- // https://heycam.github.io/webidl/#es-operations
1114
- for ( const key of ObjectKeys ( obj ) ) {
1115
- ObjectDefineProperty ( proto , key , {
1116
- __proto__ : null ,
1117
- writable : true ,
1118
- enumerable : true ,
1119
- configurable : true ,
1120
- value : obj [ key ] ,
1121
- } ) ;
1122
- }
1123
- for ( const key of ObjectGetOwnPropertySymbols ( obj ) ) {
1124
- ObjectDefineProperty ( proto , key , {
1125
- __proto__ : null ,
1126
- writable : true ,
1127
- enumerable : false ,
1128
- configurable : true ,
1129
- value : obj [ key ] ,
1130
- } ) ;
1131
- }
1132
- }
1133
-
1134
1210
// for merge sort
1135
1211
function merge ( out , start , mid , end , lBuffer , rBuffer ) {
1136
1212
const sizeLeft = mid - start ;
@@ -1160,102 +1236,6 @@ function merge(out, start, mid, end, lBuffer, rBuffer) {
1160
1236
out [ o ++ ] = rBuffer [ r ++ ] ;
1161
1237
}
1162
1238
1163
- // https://heycam.github.io/webidl/#dfn-default-iterator-object
1164
- function createSearchParamsIterator ( target , kind ) {
1165
- const iterator = { __proto__ : URLSearchParamsIteratorPrototype } ;
1166
- iterator [ context ] = {
1167
- target,
1168
- kind,
1169
- index : 0 ,
1170
- } ;
1171
- return iterator ;
1172
- }
1173
-
1174
- // https://heycam.github.io/webidl/#dfn-iterator-prototype-object
1175
- const URLSearchParamsIteratorPrototype = { __proto__ : IteratorPrototype } ;
1176
-
1177
- defineIDLClass ( URLSearchParamsIteratorPrototype , 'URLSearchParams Iterator' , {
1178
- next ( ) {
1179
- if ( ! this ||
1180
- ObjectGetPrototypeOf ( this ) !== URLSearchParamsIteratorPrototype ) {
1181
- throw new ERR_INVALID_THIS ( 'URLSearchParamsIterator' ) ;
1182
- }
1183
-
1184
- const {
1185
- target,
1186
- kind,
1187
- index,
1188
- } = this [ context ] ;
1189
- const values = target [ searchParams ] ;
1190
- const len = values . length ;
1191
- if ( index >= len ) {
1192
- return {
1193
- value : undefined ,
1194
- done : true ,
1195
- } ;
1196
- }
1197
-
1198
- const name = values [ index ] ;
1199
- const value = values [ index + 1 ] ;
1200
- this [ context ] . index = index + 2 ;
1201
-
1202
- let result ;
1203
- if ( kind === 'key' ) {
1204
- result = name ;
1205
- } else if ( kind === 'value' ) {
1206
- result = value ;
1207
- } else {
1208
- result = [ name , value ] ;
1209
- }
1210
-
1211
- return {
1212
- value : result ,
1213
- done : false ,
1214
- } ;
1215
- } ,
1216
- [ inspect . custom ] ( recurseTimes , ctx ) {
1217
- if ( this == null || this [ context ] == null || this [ context ] . target == null )
1218
- throw new ERR_INVALID_THIS ( 'URLSearchParamsIterator' ) ;
1219
-
1220
- if ( typeof recurseTimes === 'number' && recurseTimes < 0 )
1221
- return ctx . stylize ( '[Object]' , 'special' ) ;
1222
-
1223
- const innerOpts = { ...ctx } ;
1224
- if ( recurseTimes !== null ) {
1225
- innerOpts . depth = recurseTimes - 1 ;
1226
- }
1227
- const {
1228
- target,
1229
- kind,
1230
- index,
1231
- } = this [ context ] ;
1232
- const output = ArrayPrototypeReduce (
1233
- ArrayPrototypeSlice ( target [ searchParams ] , index ) ,
1234
- ( prev , cur , i ) => {
1235
- const key = i % 2 === 0 ;
1236
- if ( kind === 'key' && key ) {
1237
- ArrayPrototypePush ( prev , cur ) ;
1238
- } else if ( kind === 'value' && ! key ) {
1239
- ArrayPrototypePush ( prev , cur ) ;
1240
- } else if ( kind === 'key+value' && ! key ) {
1241
- ArrayPrototypePush ( prev , [ target [ searchParams ] [ index + i - 1 ] , cur ] ) ;
1242
- }
1243
- return prev ;
1244
- } ,
1245
- [ ] ,
1246
- ) ;
1247
- const breakLn = StringPrototypeIncludes ( inspect ( output , innerOpts ) , '\n' ) ;
1248
- const outputStrs = ArrayPrototypeMap ( output , ( p ) => inspect ( p , innerOpts ) ) ;
1249
- let outputStr ;
1250
- if ( breakLn ) {
1251
- outputStr = `\n ${ ArrayPrototypeJoin ( outputStrs , ',\n ' ) } ` ;
1252
- } else {
1253
- outputStr = ` ${ ArrayPrototypeJoin ( outputStrs , ', ' ) } ` ;
1254
- }
1255
- return `${ this [ SymbolToStringTag ] } {${ outputStr } }` ;
1256
- } ,
1257
- } ) ;
1258
-
1259
1239
function domainToASCII ( domain ) {
1260
1240
if ( arguments . length < 1 )
1261
1241
throw new ERR_MISSING_ARGS ( 'domain' ) ;
0 commit comments