@@ -26,40 +26,28 @@ import gleam/javascript/promise.{type Promise}
26
26
/// ensure correct conversions between JavaScript & Gleam.
27
27
pub type FormData
28
28
29
- /// Create a `FormData` without any data.
30
- ///
31
- /// ```gleam
32
- /// import gleam/fetch/form_data
33
- /// form_data.new()
34
- /// // -> form_data.FormData
35
- /// ```
29
+ /// Create a new empty `FormData`.
36
30
@ external ( javascript , "../../gleam_fetch_ffi.mjs" , "newFormData" )
37
31
pub fn new ( ) -> FormData
38
32
39
33
/// Append a key/string pair.
40
34
///
41
35
/// ```gleam
42
- /// import gleam/fetch/form_data
43
36
/// form_data.new()
44
37
/// |> form_data.append("key1", "value1")
45
38
/// |> form_data.append("key1", "value2")
46
39
/// |> form_data.append("key2", "value1")
47
- /// // "key1" -> ["value1", "value2"]
48
- /// // "key2" -> ["value1"]
49
40
/// ```
50
41
@ external ( javascript , "../../gleam_fetch_ffi.mjs" , "appendFormData" )
51
42
pub fn append ( form_data : FormData , key : String , value : String ) -> FormData
52
43
53
44
/// Append a key/bitarray pair.
54
45
///
55
46
/// ```gleam
56
- /// import gleam/fetch/form_data
57
47
/// form_data.new()
58
48
/// |> form_data.append_bits("key1", <<"value1">>)
59
49
/// |> form_data.append_bits("key1", <<"value2">>)
60
50
/// |> form_data.append_bits("key2", <<"value1">>)
61
- /// // "key1" -> [<<"value1">>, <<"value2">>]
62
- /// // "key2" -> [<<"value1">>]
63
51
/// ```
64
52
@ external ( javascript , "../../gleam_fetch_ffi.mjs" , "appendBitsFormData" )
65
53
pub fn append_bits (
@@ -71,33 +59,28 @@ pub fn append_bits(
71
59
/// Set key/string pair, and replace any existing value for the specified key.
72
60
///
73
61
/// ```gleam
74
- /// import gleam/fetch/form_data
75
62
/// form_data.new()
76
63
/// |> form_data.append("key1", "value1")
77
64
/// |> form_data.append_bits("key1", <<"value2">>)
78
65
/// |> form_data.set("key1", "value3")
79
- /// // "key1" -> ["value3"]
80
66
/// ```
81
67
@ external ( javascript , "../../gleam_fetch_ffi.mjs" , "setFormData" )
82
68
pub fn set ( form_data : FormData , key : String , value : String ) -> FormData
83
69
84
70
/// Set key/bitarray pair, and replace any existing value for the specified key.
85
71
///
86
72
/// ```gleam
87
- /// import gleam/fetch/form_data
88
73
/// form_data.new()
89
74
/// |> form_data.append("key1", "value1")
90
75
/// |> form_data.append_bits("key1", <<"value2">>)
91
76
/// |> form_data.set_bits("key1", <<"value3">>)
92
- /// // "key1" -> [<<"value3">>]
93
77
/// ```
94
78
@ external ( javascript , "../../gleam_fetch_ffi.mjs" , "setBitsFormData" )
95
79
pub fn set_bits ( form_data : FormData , key : String , value : BitArray ) -> FormData
96
80
97
81
/// Remove a key and all its existing values.
98
82
///
99
83
/// ```gleam
100
- /// import gleam/fetch/form_data
101
84
/// form_data.new()
102
85
/// |> form_data.append("key1", "value1")
103
86
/// |> form_data.append_bits("key1", <<"value2">>)
@@ -110,7 +93,6 @@ pub fn delete(form_data: FormData, key: String) -> FormData
110
93
/// binary values, take a look at [`get_bits`](#get_bits).
111
94
///
112
95
/// ```gleam
113
- /// import gleam/fetch/form_data
114
96
/// form_data.new()
115
97
/// |> form_data.append("key1", "value1")
116
98
/// |> form_data.append_bits("key1", <<"value2">>)
@@ -125,7 +107,6 @@ pub fn get(form_data: FormData, key: String) -> List(String)
125
107
/// a `Promise`.
126
108
///
127
109
/// ```gleam
128
- /// import gleam/fetch/form_data
129
110
/// form_data.new()
130
111
/// |> form_data.append("key1", "value1")
131
112
/// |> form_data.append_bits("key1", <<"value2">>)
0 commit comments