Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading Blob in Node environment #903

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,25 +450,7 @@ exports.prepareContent = function(name, inputData, isBinary, isOptimizedBinarySt

// if inputData is already a promise, this flatten it.
var promise = external.Promise.resolve(inputData).then(function(data) {


var isBlob = support.blob && (data instanceof Blob || ["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(data)) !== -1);

if (isBlob && typeof FileReader !== "undefined") {
return new external.Promise(function (resolve, reject) {
var reader = new FileReader();

reader.onload = function(e) {
resolve(e.target.result);
};
reader.onerror = function(e) {
reject(e.target.error);
};
reader.readAsArrayBuffer(data);
});
} else {
return data;
}
return support.blob && data instanceof Blob ? data.arrayBuffer() : data;
});

return promise.then(function(data) {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.