export default {
	downloadFile(data,opts,callback){
		if(typeof data === 'string'){
			downloadLink(data)
		} else {
			let _Blob = new Blob([data],{type:opts.type}),
			BlobURL = window.URL.createObjectURL(_Blob);
			downloadLink(BlobURL);
			window.URL.revokeObjectURL(BlobURL);
		}
		callback && callback();
		function downloadLink(url){
			const link = document.createElement('a');
			link.href = url;
			link.download = opts.name || '';
			link.style.display = 'none';
			document.body.appendChild(link);
			link.click();
			document.body.removeChild(link);
		}
	},
	copy(data,deep=true){
		return deep ? JSON.parse(JSON.stringify(data)) : Object.assign(data);
	}
}