import base64ToUnit8Array from './base64ToUnit8Array';

/**
 * Base64或dataURI转Blob对象
 * @param {*} base64 Base64或dataURI数据
 * @param {*} mimeType 文件类型
 * @returns {Blob}
 */
function base64ToBlob(base64, mimeType) {
  mimeType = mimeType || /:(.*?);/.test(base64) && RegExp.$1;
  var unit8array = base64ToUnit8Array(base64);
  return new Blob([unit8array], {
    type: mimeType
  });
}

export default base64ToBlob;
