import ArrayBufferSlice from "./ArrayBufferSlice" ; function downloadHref ( filename , href ) { const elem = document . createElement ( 'a' ) ; elem . setAttribute ( 'href' , href ) ; elem . setAttribute ( 'download' , filename ) ; document . body . appendChild ( elem ) ; elem . click ( ) ; document . body . removeChild ( elem ) ; } export function downloadBlob ( filename , blob ) { const url = window . URL . createObjectURL ( blob ) ; downloadHref ( filename , url ) ; window . URL . revokeObjectURL ( url ) ; } export function downloadBufferSlice ( filename , buffer , type = 'application/octet-stream' ) { const blob = new Blob ( [ buffer . createTypedArray ( Uint8Array ) ] , { type } ) ; downloadBlob ( filename , blob ) ; } export function downloadBuffer ( filename , buffer , type = 'application/octet-stream' ) { buffer = buffer as ArrayBuffer ; const blob = new Blob ( [ buffer ] , { type } ) ; downloadBlob ( filename , blob ) ; }