text: var thisAtob = function (str) {
    return atob(str);
  };
  
  var thisBtoa = function (str) {
    return btoa(str);
  };
  
  // Abstracts constructing a Blob object, so it also works in older
  // browsers that don't support the native Blob constructor (e.g.
  // old QtWebKit versions, Android < 4.4).
  function createBlob(parts, properties) {
    /* global BlobBuilder,MSBlobBuilder,MozBlobBuilder,WebKitBlobBuilder */
    parts = parts || [];
    properties = properties || {};
    try {
      return new Blob(parts, properties);
    } catch (e) {
      if (e.name !== "TypeError") {
        throw e;
      }
      var Builder = typeof BlobBuilder !== 'undefined' ? BlobBuilder :
                    typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder :
                    typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder :
                    WebKitBlobBuilder;
      var builder = new Builder();
      for (var i = 0; i < parts.length; i += 1) {
        builder.append(parts[i]);
      }
      return builder.getBlob(properties.type);
    }
  }
  
  // From http://stackoverflow.com/questions/14967647/ (continues on next line)
  // encode-decode-image-with-base64-breaks-image (2013-04-21)
  function binaryStringToArrayBuffer(bin) {
    var length = bin.length;
    var buf = new ArrayBuffer(length);
    var arr = new Uint8Array(buf);
    for (var i = 0; i < length; i++) {
      arr[i] = bin.charCodeAt(i);
    }
    return buf;
  }
  
  function binStringToBluffer(binString, type) {
    return createBlob([binaryStringToArrayBuffer(binString)], {type: type});
  }
  
  function b64ToBluffer(b64, type) {
    return binStringToBluffer(thisAtob(b64), type);
  }
  
  //Can't find original post, but this is close
  //http://stackoverflow.com/questions/6965107/ (continues on next line)
  //converting-between-strings-and-arraybuffers
  function arrayBufferToBinaryString(buffer) {
    var binary = '';
    var bytes = new Uint8Array(buffer);
    var length = bytes.byteLength;
    for (var i = 0; i < length; i++) {
      binary += String.fromCharCode(bytes[i]);
    }
    return binary;
  }
  
  // shim for browsers that don't support it
  function readAsBinaryString(blob, callback) {
    var reader = new FileReader();
    var hasBinaryString = typeof reader.readAsBinaryString === 'function';
    reader.onloadend = function (e) {
      var result = e.target.result || '';
      if (hasBinaryString) {
        return callback(result);
      }
      callback(arrayBufferToBinaryString(result));
    };
    if (hasBinaryString) {
      reader.readAsBinaryString(blob);
    } else {
      reader.readAsArrayBuffer(blob);
    }
  }
  
  function blobToBinaryString(blobOrBuffer, callback) {
    readAsBinaryString(blobOrBuffer, function (bin) {
      callback(bin);
    });
  }
  
  function blobToBase64(blobOrBuffer, callback) {
    blobToBinaryString(blobOrBuffer, function (base64) {
      callback(thisBtoa(base64));
    });
  }
  
  // simplified API. universal browser support is assumed
  function readAsArrayBuffer(blob, callback) {
    var reader = new FileReader();
    reader.onloadend = function (e) {
      var result = e.target.result || new ArrayBuffer(0);
      callback(result);
    };
    reader.readAsArrayBuffer(blob);
  }
  
  // this is not used in the browser
  function typedBuffer() {
  }
  
  export { thisAtob as atob, thisBtoa as btoa, b64ToBluffer as base64StringToBlobOrBuffer, binaryStringToArrayBuffer, binStringToBluffer as binaryStringToBlobOrBuffer, createBlob as blob, blobToBase64 as blobOrBufferToBase64, blobToBinaryString as blobOrBufferToBinaryString, readAsArrayBuffer, readAsBinaryString, typedBuffer };
  