fetch array buffers in cryptpad-common
This commit is contained in:
@@ -89,5 +89,15 @@ define([], function () {
|
|||||||
return Math.floor(bytes / 1024 * 100) / 100;
|
return Math.floor(bytes / 1024 * 100) / 100;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Util.fetch = function (src, cb) {
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("GET", src, true);
|
||||||
|
xhr.responseType = "arraybuffer";
|
||||||
|
xhr.onload = function () {
|
||||||
|
return void cb(void 0, new Uint8Array(xhr.response));
|
||||||
|
};
|
||||||
|
xhr.send(null);
|
||||||
|
};
|
||||||
|
|
||||||
return Util;
|
return Util;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ define([
|
|||||||
common.fixFileName = Util.fixFileName;
|
common.fixFileName = Util.fixFileName;
|
||||||
common.bytesToMegabytes = Util.bytesToMegabytes;
|
common.bytesToMegabytes = Util.bytesToMegabytes;
|
||||||
common.bytesToKilobytes = Util.bytesToKilobytes;
|
common.bytesToKilobytes = Util.bytesToKilobytes;
|
||||||
|
common.fetch = Util.fetch;
|
||||||
|
|
||||||
// import hash utilities for export
|
// import hash utilities for export
|
||||||
var createRandomHash = common.createRandomHash = Hash.createRandomHash;
|
var createRandomHash = common.createRandomHash = Hash.createRandomHash;
|
||||||
|
|||||||
Reference in New Issue
Block a user