From a8908689ccd74105ccfbc187f293a0303989b9b3 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 25 Apr 2015 17:12:18 -0400 Subject: [PATCH] (#3) - more efficient blobToArrayBuffer() --- lib/index.js | 10 ++++++++-- package.json | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 754c687..2f84236 100644 --- a/lib/index.js +++ b/lib/index.js @@ -276,8 +276,14 @@ function arrayBufferToBlob(buffer, type) { * @returns {Promise} Promise that resolves with the ArrayBuffer */ 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); }); } diff --git a/package.json b/package.json index 0ddba05..cb0d024 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "dependencies": { "blob": "0.0.4", "es3ify": "^0.1.3", - "jsdoc": "^3.3.0-alpha10", "lie": "^2.6.0" }, "devDependencies": {