support.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. exports.base64 = true;
  3. exports.array = true;
  4. exports.string = true;
  5. exports.arraybuffer = typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined";
  6. // contains true if JSZip can read/generate nodejs Buffer, false otherwise.
  7. // Browserify will provide a Buffer implementation for browsers, which is
  8. // an augmented Uint8Array (i.e., can be used as either Buffer or U8).
  9. exports.nodebuffer = typeof Buffer !== "undefined";
  10. // contains true if JSZip can read/generate Uint8Array, false otherwise.
  11. exports.uint8array = typeof Uint8Array !== "undefined";
  12. if (typeof ArrayBuffer === "undefined") {
  13. exports.blob = false;
  14. }
  15. else {
  16. var buffer = new ArrayBuffer(0);
  17. try {
  18. exports.blob = new Blob([buffer], {
  19. type: "application/zip"
  20. }).size === 0;
  21. }
  22. catch (e) {
  23. try {
  24. var Builder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
  25. var builder = new Builder();
  26. builder.append(buffer);
  27. exports.blob = builder.getBlob('application/zip').size === 0;
  28. }
  29. catch (e) {
  30. exports.blob = false;
  31. }
  32. }
  33. }