mirror of
https://github.com/nolanlawson/blob-util.git
synced 2025-12-08 19:46:19 +00:00
(#3) - more efficient blobToArrayBuffer()
This commit is contained in:
parent
fcba76d5d4
commit
a8908689cc
10
lib/index.js
10
lib/index.js
@ -276,8 +276,14 @@ function arrayBufferToBlob(buffer, type) {
|
||||
* @returns {Promise} Promise that resolves with the <code>ArrayBuffer</code>
|
||||
*/
|
||||
function blobToArrayBuffer(blob) {
|
||||
return blobToBinaryString(blob).then(function (binary) {
|
||||
return binaryStringToArrayBuffer(binary);
|
||||
return new Promise(function (resolve, reject) {
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = function (e) {
|
||||
var result = e.target.result || new ArrayBuffer(0);
|
||||
resolve(result);
|
||||
};
|
||||
reader.onerror = reject;
|
||||
reader.readAsArrayBuffer(blob);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,6 @@
|
||||
"dependencies": {
|
||||
"blob": "0.0.4",
|
||||
"es3ify": "^0.1.3",
|
||||
"jsdoc": "^3.3.0-alpha10",
|
||||
"lie": "^2.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user