@@ -13,22 +13,22 @@ export class FormData {
13
13
)
14
14
: new TypeError (
15
15
"FormData constructor: Argument 1 does not implement interface HTMLFormElement."
16
- )
16
+ ) ;
17
17
18
- throw error
18
+ throw error ;
19
19
}
20
20
21
21
/**
22
22
* @private
23
23
* @readonly
24
24
* @type {Array<[string, FormDataEntryValue]> }
25
25
*/
26
- this . _entries = [ ]
26
+ this . _entries = [ ] ;
27
27
28
- Object . defineProperty ( this , "_entries" , { enumerable : false } )
28
+ Object . defineProperty ( this , "_entries" , { enumerable : false } ) ;
29
29
}
30
30
get [ Symbol . toStringTag ] ( ) {
31
- return "FormData"
31
+ return "FormData" ;
32
32
}
33
33
34
34
/**
@@ -54,7 +54,7 @@ export class FormData {
54
54
) ,
55
55
filename
56
56
) {
57
- this . _entries . push ( [ name , toEntryValue ( value , filename ) ] )
57
+ this . _entries . push ( [ name , toEntryValue ( value , filename ) ] ) ;
58
58
}
59
59
60
60
/**
@@ -65,16 +65,16 @@ export class FormData {
65
65
delete (
66
66
name = panic ( new TypeError ( "FormData.delete: requires string argument" ) )
67
67
) {
68
- const entries = this . _entries
69
- let index = 0
68
+ const entries = this . _entries ;
69
+ let index = 0 ;
70
70
while ( index < entries . length ) {
71
71
const [ entryName ] = /** @type {[string, FormDataEntryValue] }*/ (
72
72
entries [ index ]
73
- )
73
+ ) ;
74
74
if ( entryName === name ) {
75
- entries . splice ( index , 1 )
75
+ entries . splice ( index , 1 ) ;
76
76
} else {
77
- index ++
77
+ index ++ ;
78
78
}
79
79
}
80
80
}
@@ -90,10 +90,10 @@ export class FormData {
90
90
get ( name = panic ( new TypeError ( "FormData.get: requires string argument" ) ) ) {
91
91
for ( const [ entryName , value ] of this . _entries ) {
92
92
if ( entryName === name ) {
93
- return value
93
+ return value ;
94
94
}
95
95
}
96
- return null
96
+ return null ;
97
97
}
98
98
99
99
/**
@@ -106,13 +106,13 @@ export class FormData {
106
106
getAll (
107
107
name = panic ( new TypeError ( "FormData.getAll: requires string argument" ) )
108
108
) {
109
- const values = [ ]
109
+ const values = [ ] ;
110
110
for ( const [ entryName , value ] of this . _entries ) {
111
111
if ( entryName === name ) {
112
- values . push ( value )
112
+ values . push ( value ) ;
113
113
}
114
114
}
115
- return values
115
+ return values ;
116
116
}
117
117
118
118
/**
@@ -124,10 +124,10 @@ export class FormData {
124
124
has ( name = panic ( new TypeError ( "FormData.has: requires string argument" ) ) ) {
125
125
for ( const [ entryName ] of this . _entries ) {
126
126
if ( entryName === name ) {
127
- return true
127
+ return true ;
128
128
}
129
129
}
130
- return false
130
+ return false ;
131
131
}
132
132
133
133
/**
@@ -144,27 +144,27 @@ export class FormData {
144
144
value = panic ( new TypeError ( "FormData.set: requires at least 2 arguments" ) ) ,
145
145
filename
146
146
) {
147
- let index = 0
148
- const { _entries : entries } = this
149
- const entryValue = toEntryValue ( value , filename )
150
- let wasSet = false
147
+ let index = 0 ;
148
+ const { _entries : entries } = this ;
149
+ const entryValue = toEntryValue ( value , filename ) ;
150
+ let wasSet = false ;
151
151
while ( index < entries . length ) {
152
- const entry = /** @type {[string, FormDataEntryValue] }*/ ( entries [ index ] )
152
+ const entry = /** @type {[string, FormDataEntryValue] }*/ ( entries [ index ] ) ;
153
153
if ( entry [ 0 ] === name ) {
154
154
if ( wasSet ) {
155
- entries . splice ( index , 1 )
155
+ entries . splice ( index , 1 ) ;
156
156
} else {
157
- wasSet = true
158
- entry [ 1 ] = entryValue
159
- index ++
157
+ wasSet = true ;
158
+ entry [ 1 ] = entryValue ;
159
+ index ++ ;
160
160
}
161
161
} else {
162
- index ++
162
+ index ++ ;
163
163
}
164
164
}
165
165
166
166
if ( ! wasSet ) {
167
- entries . push ( [ name , entryValue ] )
167
+ entries . push ( [ name , entryValue ] ) ;
168
168
}
169
169
}
170
170
@@ -173,7 +173,7 @@ export class FormData {
173
173
* contained in this object.
174
174
*/
175
175
entries ( ) {
176
- return this . _entries . values ( )
176
+ return this . _entries . values ( ) ;
177
177
}
178
178
179
179
/**
@@ -184,7 +184,7 @@ export class FormData {
184
184
*/
185
185
* keys ( ) {
186
186
for ( const [ name ] of this . _entries ) {
187
- yield name
187
+ yield name ;
188
188
}
189
189
}
190
190
@@ -196,12 +196,12 @@ export class FormData {
196
196
*/
197
197
* values ( ) {
198
198
for ( const [ _ , value ] of this . _entries ) {
199
- yield value
199
+ yield value ;
200
200
}
201
201
}
202
202
203
203
[ Symbol . iterator ] ( ) {
204
- return this . _entries . values ( )
204
+ return this . _entries . values ( ) ;
205
205
}
206
206
207
207
/**
@@ -211,7 +211,7 @@ export class FormData {
211
211
*/
212
212
forEach ( fn , thisArg ) {
213
213
for ( const [ key , value ] of this . _entries ) {
214
- fn . call ( thisArg , value , key , this )
214
+ fn . call ( thisArg , value , key , this ) ;
215
215
}
216
216
}
217
217
}
@@ -220,8 +220,8 @@ export class FormData {
220
220
* @param {any } value
221
221
* @returns {value is HTMLFormElement }
222
222
*/
223
- const isHTMLFormElement = value =>
224
- Object . prototype . toString . call ( value ) === "[object HTMLFormElement]"
223
+ const isHTMLFormElement = ( value ) =>
224
+ Object . prototype . toString . call ( value ) === "[object HTMLFormElement]" ;
225
225
226
226
/**
227
227
* @param {string|Blob|File } value
@@ -230,33 +230,33 @@ const isHTMLFormElement = value =>
230
230
*/
231
231
const toEntryValue = ( value , filename ) => {
232
232
if ( isFile ( value ) ) {
233
- return filename != null ? new BlobFile ( [ value ] , filename , value ) : value
233
+ return filename != null ? new BlobFile ( [ value ] , filename , value ) : value ;
234
234
} else if ( isBlob ( value ) ) {
235
- return new BlobFile ( [ value ] , filename != null ? filename : "blob" )
235
+ return new BlobFile ( [ value ] , filename != null ? filename : "blob" ) ;
236
236
} else {
237
- if ( filename != null ) {
237
+ if ( filename != null && filename != "" ) {
238
238
throw new TypeError (
239
239
"filename is only supported when value is Blob or File"
240
- )
240
+ ) ;
241
241
}
242
- return `${ value } `
242
+ return `${ value } ` ;
243
243
}
244
- }
244
+ } ;
245
245
246
246
/**
247
247
* @param {any } value
248
248
* @returns {value is File }
249
249
*/
250
- const isFile = value =>
250
+ const isFile = ( value ) =>
251
251
Object . prototype . toString . call ( value ) === "[object File]" &&
252
- typeof value . name === "string"
252
+ typeof value . name === "string" ;
253
253
254
254
/**
255
255
* @param {any } value
256
256
* @returns {value is Blob }
257
257
*/
258
- const isBlob = value =>
259
- Object . prototype . toString . call ( value ) === "[object Blob]"
258
+ const isBlob = ( value ) =>
259
+ Object . prototype . toString . call ( value ) === "[object Blob]" ;
260
260
261
261
/**
262
262
* Simple `File` implementation that just wraps a given blob.
@@ -269,18 +269,18 @@ const BlobFile = class File {
269
269
* @param {FilePropertyBag } [options]
270
270
*/
271
271
constructor ( [ blob ] , name , { lastModified = Date . now ( ) } = { } ) {
272
- this . blob = blob
273
- this . name = name
274
- this . lastModified = lastModified
272
+ this . blob = blob ;
273
+ this . name = name ;
274
+ this . lastModified = lastModified ;
275
275
}
276
276
get webkitRelativePath ( ) {
277
- return ""
277
+ return "" ;
278
278
}
279
279
get size ( ) {
280
- return this . blob . size
280
+ return this . blob . size ;
281
281
}
282
282
get type ( ) {
283
- return this . blob . type
283
+ return this . blob . type ;
284
284
}
285
285
/**
286
286
*
@@ -289,26 +289,26 @@ const BlobFile = class File {
289
289
* @param {string } [contentType]
290
290
*/
291
291
slice ( start , end , contentType ) {
292
- return this . blob . slice ( start , end , contentType )
292
+ return this . blob . slice ( start , end , contentType ) ;
293
293
}
294
294
stream ( ) {
295
- return this . blob . stream ( )
295
+ return this . blob . stream ( ) ;
296
296
}
297
297
text ( ) {
298
- return this . blob . text ( )
298
+ return this . blob . text ( ) ;
299
299
}
300
300
arrayBuffer ( ) {
301
- return this . blob . arrayBuffer ( )
301
+ return this . blob . arrayBuffer ( ) ;
302
302
}
303
303
get [ Symbol . toStringTag ] ( ) {
304
- return "File"
304
+ return "File" ;
305
305
}
306
- }
306
+ } ;
307
307
308
308
/**
309
309
* @param {* } error
310
310
* @returns {never }
311
311
*/
312
- const panic = error => {
313
- throw error
314
- }
312
+ const panic = ( error ) => {
313
+ throw error ;
314
+ } ;
0 commit comments