type ExtensionMap = Record < string , boolean > ; readonly memberof const extensions = [ 'mp3' , 'ogg' , 'oga' , 'opus' , 'mpeg' , 'wav' , 'm4a' , 'aiff' , 'wma' , 'mid' , 'caf' , ] ; readonly memberof property property property property property property property property property property const supported = { } ; memberof param typeOverrides function validateFormats ( typeOverrides ? ) { const overrides = { m4a : 'audio/mp4' , oga : 'audio/ogg' , opus : 'audio/ogg; codecs="opus"' , caf : 'audio/x-caf; codecs="opus"' , ... ( typeOverrides || { } ) } ; const audio = document . createElement ( 'audio' ) ; const formats = { } ; const no = /^no$/ ; extensions . forEach ( ( ext ) => { const canByExt = audio . canPlayType ( `audio/${ ext }` ) . replace ( no , '' ) ; const canByType = overrides [ ext ] ? audio . canPlayType ( overrides [ ext ] ) . replace ( no , '' ) : '' ; formats [ ext ] = ! ! canByExt || ! ! canByType ; } ) ; Object . assign ( supported , formats ) ; } validateFormats ( ) ; export { validateFormats , supported , extensions } ;