@vuelancer/extension-checker
v1.0.1
Published
Extension checker for files like image, video, document
Downloads
3
Readme
@vuelancer/extension-checker
Extension checker for image, video and documents!
- Usage:
const checker = require("@vuelancer/extension-checker)
function getExtension(filename) {
var parts = filename.split(".");
return parts[parts.length - 1];
}
function imageExtensionFinder(filename) {
var ext = getExtension(filename);
switch (ext.toLowerCase()) {
case "jpg":
return "jpg";
case "jpeg":
return "jpeg";
case "gif":
return "gif";
case "bmp":
return "bmp";
case "png":
return "png";
}
return null;
}
function videoExtensionFinder(filename) {
var ext = getExtension(filename);
switch (ext.toLowerCase()) {
case "m4v":
return "m4v";
case "avi":
return "avi";
case "mpg":
return "mpg";
case "mp4":
return "mp4";
}
return null;
}
function documentExtensionFinder(filename) {
var ext = getExtension(filename);
switch (ext.toLowerCase()) {
case "pdf":
return "pdf";
case "docx":
return "docx";
case "doc":
return "doc";
}
return null;
}
export default {
imageExtensionFinder,
videoExtensionFinder,
documentExtensionFinder,
};