Skip to content

Commit 54a2374

Browse files
committed
chore(fix): 🐛 formdata
1 parent 26cd17b commit 54a2374

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/util/formData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export function objectToFormData(
22
object,
33
formData = new FormData(),
44
parent = null,
5-
) {
5+
): FormData | void {
66
if (object === null || object === 'undefined' || object.length === 0) {
77
return formData.append(parent, object)
88
}

src/util/objects.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
import { isMatch } from './matcher'
22

3-
export function isArray(object: any) {
3+
export function isArray(object: any): boolean {
44
return Object.prototype.toString.call(object) === '[object Array]'
55
}
66

7-
export function isFile(object: any) {
7+
export function isFile(object: any): boolean {
8+
if (typeof File !== 'function' || typeof FileList !== 'function') {
9+
return false
10+
}
811
return object instanceof File || object instanceof FileList
912
}
1013

11-
export function merge(a: string | any, b: string | any) {
14+
export function merge(a: string | any, b: string | any): void {
1215
for (const key in b) {
16+
if (!b.hasOwnProperty(key)) {
17+
continue
18+
}
1319
a[key] = cloneDeep(b[key])
1420
}
1521
}
1622

17-
export function cloneDeep(object: any) {
23+
export function cloneDeep(object: any): any {
1824
if (object === null) {
1925
return null
2026
}

0 commit comments

Comments
 (0)