MCPcopy Index your code
hub / github.com/nodejs/node / URLSearchParamsIterator

Class URLSearchParamsIterator

lib/internal/url.js:224–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222let setURLSearchParams;
223
224class URLSearchParamsIterator {
225 #target;
226 #kind;
227 #index;
228
229 // https://heycam.github.io/webidl/#dfn-default-iterator-object
230 constructor(target, kind) {
231 this.#target = target;
232 this.#kind = kind;
233 this.#index = 0;
234 }
235
236 next() {
237 if (typeof this !== 'object' || this === null || !(#target in this))
238 throw new ERR_INVALID_THIS('URLSearchParamsIterator');
239
240 const index = this.#index;
241 const values = getURLSearchParamsList(this.#target);
242 const len = values.length;
243 if (index >= len) {
244 return {
245 done: true,
246 value: undefined,
247 };
248 }
249
250 const name = values[index];
251 const value = values[index + 1];
252 this.#index = index + 2;
253
254 let result;
255 if (this.#kind === 'key') {
256 result = name;
257 } else if (this.#kind === 'value') {
258 result = value;
259 } else {
260 result = [name, value];
261 }
262
263 return {
264 done: false,
265 value: result,
266 };
267 }
268
269 [inspect.custom](recurseTimes, ctx) {
270 if (!this || typeof this !== 'object' || !(#target in this))
271 throw new ERR_INVALID_THIS('URLSearchParamsIterator');
272
273 if (typeof recurseTimes === 'number' && recurseTimes < 0)
274 return ctx.stylize('[Object]', 'special');
275
276 const innerOpts = { ...ctx };
277 if (recurseTimes !== null) {
278 innerOpts.depth = recurseTimes - 1;
279 }
280 const index = this.#index;
281 const values = getURLSearchParamsList(this.#target);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…