export function urlB64ToUint8Array ( base64String ) { const padding = '=' . repeat ( ( 4 - base64String . length % 4 ) % 4 ) ; const base64 = ( base64String + padding ) . replace ( /\-/g , '+' ) . replace ( /_/g , '/' ) ; const rawData = window . atob ( base64 ) ; const outputArray = new Uint8Array ( rawData . length ) ; for ( let i = 0 ; i < rawData . length ; ++ i ) { outputArray [ i ] = rawData . charCodeAt ( i ) ; } return outputArray ; } export function formatBytes ( bytes , decimals ? ) { if ( bytes == 0 ) return '0 Bytes' ; var k = 1024 , dm = decimals || 2 , sizes = [ 'Bytes' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' ] , i = Math . floor ( Math . log ( bytes ) / Math . log ( k ) ) ; return parseFloat ( ( bytes / Math . pow ( k , i ) ) . toFixed ( dm ) ) + ' ' + sizes [ i ] ; } export function checkAnon ( ) { if ( sessionStorage !== undefined ) { return sessionStorage . getItem ( 'anon' ) ; } } export function debounce ( fn , delay ) { let timer = null ; return function ( ) { const context = this , args = arguments ; clearTimeout ( timer ) ; timer = setTimeout ( function ( ) { fn . apply ( context , args ) ; } , delay ) ; } ; }