@zimic/http 0.5.0 → 0.5.1-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -82,64 +82,42 @@ var HttpFormData = class extends FormData {
82
82
  super.append(name, blobOrValue, fileName);
83
83
  }
84
84
  }
85
- /**
86
- * Get the value of the entry associated to a key name.
87
- *
88
- * If the key might have multiple values, use {@link HttpFormData#getAll} instead.
89
- *
90
- * @param name The name of the key to get the value of.
91
- * @returns The value associated with the key name, or `null` if the key does not exist.
92
- * @see {@link https://developer.mozilla.org/docs/Web/API/FormData/get MDN Reference}
93
- */
85
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataget `formData.get()` API reference} */
94
86
  get(name) {
95
87
  return super.get(name);
96
88
  }
97
- /**
98
- * Get all the values of the entry associated with a key name.
99
- *
100
- * If the key has at most a single value, use {@link HttpFormData#get} instead.
101
- *
102
- * @param name The name of the key to get the values of.
103
- * @returns An array of values associated with the key name, or an empty array if the key does not exist.
104
- * @see {@link https://developer.mozilla.org/docs/Web/API/FormData/getAll MDN Reference}
105
- */
89
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatagetall `formData.getAll()` API reference} */
106
90
  getAll(name) {
107
91
  return super.getAll(name);
108
92
  }
109
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/has MDN Reference} */
93
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatahas `formData.has()` API reference} */
110
94
  has(name) {
111
95
  return super.has(name);
112
96
  }
113
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/delete MDN Reference} */
97
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatadelete `formData.delete()` API reference} */
114
98
  delete(name) {
115
99
  super.delete(name);
116
100
  }
101
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforEach `formData.forEach()` API reference} */
117
102
  forEach(callback, thisArg) {
118
103
  super.forEach(callback, thisArg);
119
104
  }
120
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/keys MDN Reference} */
105
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatakeys `formData.keys()` API reference} */
121
106
  keys() {
122
107
  return super.keys();
123
108
  }
124
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/values MDN Reference} */
109
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatavalues `formData.values()` API reference} */
125
110
  values() {
126
111
  return super.values();
127
112
  }
128
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/entries MDN Reference} */
113
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataentries `formData.entries()` API reference} */
129
114
  entries() {
130
115
  return super.entries();
131
116
  }
132
117
  [Symbol.iterator]() {
133
118
  return super[Symbol.iterator]();
134
119
  }
135
- /**
136
- * Checks if the data is equal to the other data. Equality is defined as having the same keys and values, regardless
137
- * of the order of keys.
138
- *
139
- * @param otherData The other data to compare.
140
- * @returns A promise that resolves with `true` if the data is equal to the other data, or `false` otherwise.
141
- * Important: both form data might be read while comparing.
142
- */
120
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataequals `formData.equals()` API reference} */
143
121
  async equals(otherData) {
144
122
  if (!await this.contains(otherData)) {
145
123
  return false;
@@ -152,14 +130,7 @@ var HttpFormData = class extends FormData {
152
130
  }
153
131
  return true;
154
132
  }
155
- /**
156
- * Checks if the data contains the other data. This method is less strict than {@link HttpFormData#equals} and only
157
- * requires that all keys and values in the other data are present in this data.
158
- *
159
- * @param otherData The other data to compare.
160
- * @returns A promise that resolves with `true` if this data contains the other data, or `false` otherwise. Important:
161
- * both form data might be read while comparing.
162
- */
133
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatacontains `formData.contains()` API reference} */
163
134
  async contains(otherData) {
164
135
  for (const [otherKey, otherValue] of otherData.entries()) {
165
136
  const values = super.getAll.call(this, otherKey);
@@ -180,30 +151,7 @@ var HttpFormData = class extends FormData {
180
151
  }
181
152
  return true;
182
153
  }
183
- /**
184
- * Converts this form data into a plain object. This method is useful for serialization and debugging purposes.
185
- *
186
- * **NOTE**: If a key has multiple values, the object will contain an array of values for that key. If the key has
187
- * only one value, the object will contain its value directly, without an array, regardless of how the value was
188
- * initialized when creating the form data.
189
- *
190
- * @example
191
- * const formData = new HttpFormData<{
192
- * title: string;
193
- * descriptions: string[];
194
- * content: Blob;
195
- * }>();
196
- *
197
- * formData.set('title', 'My title');
198
- * formData.append('descriptions', 'Description 1');
199
- * formData.append('descriptions', 'Description 2');
200
- * formData.set('content', new Blob(['content'], { type: 'text/plain' }));
201
- *
202
- * const object = formData.toObject();
203
- * console.log(object); // { title: 'My title', descriptions: ['Description 1', 'Description 2'], content: Blob { type: 'text/plain' } }
204
- *
205
- * @returns A plain object representation of this form data.
206
- */
154
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatatoobject `formData.toObject()` API reference} */
207
155
  toObject() {
208
156
  const object = {};
209
157
  for (const [key, value] of this.entries()) {
@@ -245,55 +193,50 @@ var HttpHeaders = class extends Headers {
245
193
  super(pickPrimitiveProperties(init));
246
194
  }
247
195
  }
248
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/set MDN Reference} */
196
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersset `headers.set()` API reference} */
249
197
  set(name, value) {
250
198
  super.set(name, value);
251
199
  }
252
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/append MDN Reference} */
200
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersappend `headers.append()` API reference} */
253
201
  append(name, value) {
254
202
  super.append(name, value);
255
203
  }
256
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/get MDN Reference} */
204
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersget `headers.get()` API reference} */
257
205
  get(name) {
258
206
  return super.get(name);
259
207
  }
260
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/has MDN Reference} */
208
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetSetCookie `headers.getSetCookie()` API reference} */
261
209
  getSetCookie() {
262
210
  return super.getSetCookie();
263
211
  }
264
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/has MDN Reference} */
212
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headershas `headers.has()` API reference} */
265
213
  has(name) {
266
214
  return super.has(name);
267
215
  }
268
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/delete MDN Reference} */
216
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersdelete `headers.delete()` API reference} */
269
217
  delete(name) {
270
218
  super.delete(name);
271
219
  }
220
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforEach `headers.forEach()` API reference} */
272
221
  forEach(callback, thisArg) {
273
222
  super.forEach(callback, thisArg);
274
223
  }
275
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/keys MDN Reference} */
224
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerskeys `headers.keys()` API reference} */
276
225
  keys() {
277
226
  return super.keys();
278
227
  }
279
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/values MDN Reference} */
228
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersvalues `headers.values()` API reference} */
280
229
  values() {
281
230
  return super.values();
282
231
  }
283
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/entries MDN Reference} */
232
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersentries `headers.entries()` API reference} */
284
233
  entries() {
285
234
  return super.entries();
286
235
  }
287
236
  [Symbol.iterator]() {
288
237
  return super[Symbol.iterator]();
289
238
  }
290
- /**
291
- * Checks if this headers object is equal to another set of headers. Equality is defined as having the same keys and
292
- * values, regardless of the order of keys.
293
- *
294
- * @param otherHeaders The other headers object to compare against.
295
- * @returns `true` if the headers are equal, `false` otherwise.
296
- */
239
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersequals `headers.equals()` API reference} */
297
240
  equals(otherHeaders) {
298
241
  if (!this.contains(otherHeaders)) {
299
242
  return false;
@@ -306,14 +249,7 @@ var HttpHeaders = class extends Headers {
306
249
  }
307
250
  return true;
308
251
  }
309
- /**
310
- * Checks if this headers object contains another set of headers. This method is less strict than
311
- * {@link HttpHeaders#equals} and only requires that all keys and values in the other headers are present in these
312
- * headers.
313
- *
314
- * @param otherHeaders The other headers object to compare against.
315
- * @returns `true` if these headers contain the other headers, `false` otherwise.
316
- */
252
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerscontains `headers.contains()` API reference} */
317
253
  contains(otherHeaders) {
318
254
  for (const [key, otherValue] of otherHeaders.entries()) {
319
255
  const value = super.get.call(this, key);
@@ -396,82 +332,54 @@ var HttpSearchParams = class extends URLSearchParams {
396
332
  }
397
333
  }
398
334
  }
399
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/set MDN Reference} */
335
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsset `searchParams.set()` API reference} */
400
336
  set(name, value) {
401
337
  super.set(name, value);
402
338
  }
403
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/append MDN Reference} */
339
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsappend `searchParams.append()` API reference} */
404
340
  append(name, value) {
405
341
  super.append(name, value);
406
342
  }
407
- /**
408
- * Get the value of the entry associated to a key name.
409
- *
410
- * If the key might have multiple values, use {@link HttpSearchParams#getAll} instead.
411
- *
412
- * @param name The name of the key to get the value of.
413
- * @returns The value associated with the key name, or `null` if the key does not exist.
414
- * @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/get MDN Reference}
415
- */
343
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsget `searchParams.get()` API reference} */
416
344
  get(name) {
417
345
  return super.get(name);
418
346
  }
419
- /**
420
- * Get all the values of the entry associated with a key name.
421
- *
422
- * If the key has at most one value, use {@link HttpSearchParams#get} instead.
423
- *
424
- * @param name The name of the key to get the values of.
425
- * @returns An array of values associated with the key name, or an empty array if the key does not exist.
426
- * @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll MDN Reference}
427
- */
347
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsgetall `searchParams.getAll()` API reference} */
428
348
  getAll(name) {
429
349
  return super.getAll(name);
430
350
  }
431
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/has MDN Reference} */
351
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamshas `searchParams.has()` API reference} */
432
352
  has(name, value) {
433
353
  return super.has(name, value);
434
354
  }
435
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete MDN Reference} */
355
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsdelete `searchParams.delete()` API reference} */
436
356
  delete(name, value) {
437
357
  super.delete(name, value);
438
358
  }
359
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforEach `searchParams.forEach()` API reference} */
439
360
  forEach(callback, thisArg) {
440
361
  super.forEach(callback, thisArg);
441
362
  }
442
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/keys MDN Reference} */
363
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamskeys `searchParams.keys()` API reference} */
443
364
  keys() {
444
365
  return super.keys();
445
366
  }
446
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/values MDN Reference} */
367
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsvalues `searchParams.values()` API reference} */
447
368
  values() {
448
369
  return super.values();
449
370
  }
450
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/entries MDN Reference} */
371
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsentries `searchParams.entries()` API reference} */
451
372
  entries() {
452
373
  return super.entries();
453
374
  }
454
375
  [Symbol.iterator]() {
455
376
  return super[Symbol.iterator]();
456
377
  }
457
- /**
458
- * Checks if these search params are equal to another set of search parameters. Equality is defined as having the same
459
- * keys and values, regardless of the order of the keys.
460
- *
461
- * @param otherParams The other search parameters to compare against.
462
- * @returns `true` if the search parameters are equal, `false` otherwise.
463
- */
378
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsequals `searchParams.equals()` API reference} */
464
379
  equals(otherParams) {
465
380
  return this.contains(otherParams) && this.size === otherParams.size;
466
381
  }
467
- /**
468
- * Checks if these search params contain another set of search parameters. This method is less strict than
469
- * {@link HttpSearchParams#equals} and only requires that all keys and values in the other search parameters are
470
- * present in these search parameters.
471
- *
472
- * @param otherParams The other search parameters to check for containment.
473
- * @returns `true` if these search parameters contain the other search parameters, `false` otherwise.
474
- */
382
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamscontains `searchParams.contains()` API reference} */
475
383
  contains(otherParams) {
476
384
  for (const [key, otherValue] of otherParams.entries()) {
477
385
  const values = super.getAll.call(this, key);
@@ -486,24 +394,7 @@ var HttpSearchParams = class extends URLSearchParams {
486
394
  }
487
395
  return true;
488
396
  }
489
- /**
490
- * Converts these search params into a plain object. This method is useful for serialization and debugging purposes.
491
- *
492
- * **NOTE**: If a key has multiple values, the object will contain an array of values for that key. If the key has
493
- * only one value, the object will contain its value directly, without an array, regardless of how the value was
494
- * initialized when creating the search params object.
495
- *
496
- * @example
497
- * const searchParams = new HttpSearchParams({
498
- * names: ['user 1', 'user 2'],
499
- * name: ['user 3'],
500
- * page: '1',
501
- * });
502
- * const object = searchParams.toObject();
503
- * console.log(object); // { names: ['user 1', 'user 2'], name: 'user 3', page: '1' }
504
- *
505
- * @returns A plain object representation of these search params.
506
- */
397
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamstoobject `searchParams.toObject()` API reference} */
507
398
  toObject() {
508
399
  const object = {};
509
400
  for (const [key, value] of this.entries()) {