-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
94 lines (75 loc) · 1.83 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
export default file => {
/*
* Compare MIME type of file object using respective methods.
*
* @param {Object} file - File object that gets its 'type' property compared
*/
const checkingFile = file
const anImage = () => {
/*
* Check if file is an image
*
* returns Boolean
*/
return checkingFile.type.indexOf('image/') != -1 ? true : false
}
const anAudio = () => {
/*
* Check if file is an audio file
*
* returns Boolean
*/
return checkingFile.type.indexOf('audio/') != -1 ? true : false
}
const aMP3 = () => {
/*
* Check if file is an MP3 file
*
* returns Boolean
*/
return checkingFile.type.indexOf('audio/mpeg3') != -1 ? true : false ||
checkingFile.type.indexOf('audio/x-mpeg-3') != -1 ? true : false
}
const aVideo = () => {
/*
* Check if file is an video file
*
* returns Boolean
*/
return checkingFile.type.indexOf('video/') != -1 ? true : false
}
const aMP4 = () => {
/*
* Check if file is an MP4
*
* returns Boolean
*/
return checkingFile.type.indexOf('video/mp4') != -1 ? true : false
}
const multimedia = () => {
/*
* Check if file is a multimedia,
*
* returns Boolean
*/
return anAudio() || aVideo() || anImage()
}
const aPDF = () => {
/*
* Check if file is a PDF
*
* returns Boolean
*/
checkingFile.type.indexOf('audio/x-mpeg-3') != -1 ? true : falsee
}
const aSpreadsheet = () => {
/*
* Check if file is a spreadsheet
*
* returns Boolean
*/
return checkingFile.type.indexOf('excel') != -1 ? true : false ||
checkingFile.type.indexOf('spreadsheetml') != -1 ? true : false
}
return { anImage, anAudio, aMP3, aVideo, aMP4, multimedia, aPDF, aSpreadsheet }
}