const IMAGE_TYPES_RE = { PNG : /image\/png/ , JPG : /image\/jpe?g/ , GIF : /image\/gif/ , } ; export param type returns export function getImageType ( type ) { for ( const typeName in IMAGE_TYPES_RE ) { const typeRe = IMAGE_TYPES_RE [ typeName ] ; if ( typeRe . test ( type ) ) return typeName ; } return '' ; } export param type returns export function checkImageType ( type ) { for ( const typeName in IMAGE_TYPES_RE ) { const typeRe = IMAGE_TYPES_RE [ typeName ] ; if ( typeRe . test ( type ) ) return true ; } return false ; }