|
1 | 1 | import {FileLike} from "./FileLike"
|
2 | 2 |
|
3 | 3 | /**
|
4 |
| - * This interface reflects possible values of each FormData entry |
| 4 | + * A `string` or `File` that represents a single value from a set of `FormData` key-value pairs. |
5 | 5 | */
|
6 | 6 | export type FormDataEntryValue = string | FileLike
|
7 | 7 |
|
8 | 8 | /**
|
9 | 9 | * This interface reflects minimal shape of the FormData
|
10 | 10 | */
|
11 | 11 | export interface FormDataLike {
|
12 |
| - append(name: string, value: unknown, filename?: string): void |
| 12 | + /** |
| 13 | + * Appends a new value onto an existing key inside a FormData object, |
| 14 | + * or adds the key if it does not already exist. |
| 15 | + * |
| 16 | + * The difference between `set()` and `append()` is that if the specified key already exists, `set()` will overwrite all existing values with the new one, whereas `append()` will append the new value onto the end of the existing set of values. |
| 17 | + * |
| 18 | + * @param name The name of the field whose data is contained in `value`. |
| 19 | + * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) |
| 20 | + or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string. |
| 21 | + * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename. |
| 22 | + */ |
| 23 | + append(name: string, value: unknown, fileName?: string): void |
13 | 24 |
|
| 25 | + /** |
| 26 | + * Returns all the values associated with a given key from within a `FormData` object. |
| 27 | + * |
| 28 | + * @param {string} name A name of the value you want to retrieve. |
| 29 | + * |
| 30 | + * @returns An array of `FormDataEntryValue` whose key matches the value passed in the `name` parameter. If the key doesn't exist, the method returns an empty list. |
| 31 | + */ |
14 | 32 | getAll(name: string): FormDataEntryValue[]
|
15 | 33 |
|
| 34 | + /** |
| 35 | + * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through the `FormData` key/value pairs. |
| 36 | + * The key of each pair is a string; the value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue). |
| 37 | + */ |
16 | 38 | entries(): Generator<[string, FormDataEntryValue]>
|
17 | 39 |
|
| 40 | + /** |
| 41 | + * An alias for FormDataLike#entries() |
| 42 | + */ |
18 | 43 | [Symbol.iterator](): Generator<[string, FormDataEntryValue]>
|
19 | 44 |
|
20 | 45 | [Symbol.toStringTag]: string
|
|
0 commit comments