Skip to content

Commit

Permalink
[api-minor] Remove the obsolete createBlob helper function
Browse files Browse the repository at this point in the history
At this point in time, all supported browsers have native support for `Blob`; please see https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob#Browser_compatibility.
Furthermore, note how the helper function was throwing an error if `Blob` isn't available anyway.
  • Loading branch information
Snuffleupagus committed Aug 19, 2018
1 parent 160ca55 commit 50a47be
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
1 change: 0 additions & 1 deletion src/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
exports.shadow = pdfjsSharedUtil.shadow;
exports.createBlob = pdfjsSharedUtil.createBlob;
exports.Util = pdfjsSharedUtil.Util;
exports.ReadableStream = pdfjsSharedUtil.ReadableStream;
exports.URL = pdfjsSharedUtil.URL;
Expand Down
10 changes: 1 addition & 9 deletions src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,21 +969,14 @@ function createPromiseCapability() {
return capability;
}

var createBlob = function createBlob(data, contentType) {
if (typeof Blob !== 'undefined') {
return new Blob([data], { type: contentType, });
}
throw new Error('The "Blob" constructor is not supported.');
};

var createObjectURL = (function createObjectURLClosure() {
// Blob/createObjectURL is not available, falling back to data schema.
var digits =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';

return function createObjectURL(data, contentType, forceDataSchema = false) {
if (!forceDataSchema && URL.createObjectURL) {
var blob = createBlob(data, contentType);
const blob = new Blob([data], { type: contentType, });
return URL.createObjectURL(blob);
}

Expand Down Expand Up @@ -1033,7 +1026,6 @@ export {
arraysToBytes,
assert,
bytesToString,
createBlob,
createPromiseCapability,
createObjectURL,
deprecated,
Expand Down
10 changes: 5 additions & 5 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import {
TextLayerMode
} from './ui_utils';
import {
build, createBlob, createObjectURL, getDocument, getFilenameFromUrl,
GlobalWorkerOptions, InvalidPDFException, LinkTarget, loadScript,
MissingPDFException, OPS, PDFWorker, shadow, UnexpectedResponseException,
UNSUPPORTED_FEATURES, URL, version
build, createObjectURL, getDocument, getFilenameFromUrl, GlobalWorkerOptions,
InvalidPDFException, LinkTarget, loadScript, MissingPDFException, OPS,
PDFWorker, shadow, UnexpectedResponseException, UNSUPPORTED_FEATURES, URL,
version
} from 'pdfjs-lib';
import { CursorTool, PDFCursorTools } from './pdf_cursor_tools';
import { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';
Expand Down Expand Up @@ -748,7 +748,7 @@ let PDFViewerApplication = {
}

this.pdfDocument.getData().then(function(data) {
let blob = createBlob(data, 'application/pdf');
const blob = new Blob([data], { type: 'application/pdf', });
downloadManager.download(blob, url, filename);
}).catch(downloadByUrl); // Error occurred, try downloading with the URL.
},
Expand Down

0 comments on commit 50a47be

Please sign in to comment.