Merge pull request #9987 from Snuffleupagus/rm-createBlob

[api-minor] Remove the obsolete `createBlob` helper function
This commit is contained in:
Tim van der Meij 2018-08-19 16:43:36 +02:00 committed by GitHub
commit 4ea663aa8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 15 deletions

View File

@ -101,7 +101,6 @@ exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
exports.createObjectURL = pdfjsSharedUtil.createObjectURL; exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters; exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
exports.shadow = pdfjsSharedUtil.shadow; exports.shadow = pdfjsSharedUtil.shadow;
exports.createBlob = pdfjsSharedUtil.createBlob;
exports.Util = pdfjsSharedUtil.Util; exports.Util = pdfjsSharedUtil.Util;
exports.ReadableStream = pdfjsSharedUtil.ReadableStream; exports.ReadableStream = pdfjsSharedUtil.ReadableStream;
exports.URL = pdfjsSharedUtil.URL; exports.URL = pdfjsSharedUtil.URL;

View File

@ -969,13 +969,6 @@ function createPromiseCapability() {
return capability; 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() { var createObjectURL = (function createObjectURLClosure() {
// Blob/createObjectURL is not available, falling back to data schema. // Blob/createObjectURL is not available, falling back to data schema.
var digits = var digits =
@ -983,7 +976,7 @@ var createObjectURL = (function createObjectURLClosure() {
return function createObjectURL(data, contentType, forceDataSchema = false) { return function createObjectURL(data, contentType, forceDataSchema = false) {
if (!forceDataSchema && URL.createObjectURL) { if (!forceDataSchema && URL.createObjectURL) {
var blob = createBlob(data, contentType); const blob = new Blob([data], { type: contentType, });
return URL.createObjectURL(blob); return URL.createObjectURL(blob);
} }
@ -1033,7 +1026,6 @@ export {
arraysToBytes, arraysToBytes,
assert, assert,
bytesToString, bytesToString,
createBlob,
createPromiseCapability, createPromiseCapability,
createObjectURL, createObjectURL,
deprecated, deprecated,

View File

@ -21,10 +21,10 @@ import {
TextLayerMode TextLayerMode
} from './ui_utils'; } from './ui_utils';
import { import {
build, createBlob, createObjectURL, getDocument, getFilenameFromUrl, build, createObjectURL, getDocument, getFilenameFromUrl, GlobalWorkerOptions,
GlobalWorkerOptions, InvalidPDFException, LinkTarget, loadScript, InvalidPDFException, LinkTarget, loadScript, MissingPDFException, OPS,
MissingPDFException, OPS, PDFWorker, shadow, UnexpectedResponseException, PDFWorker, shadow, UnexpectedResponseException, UNSUPPORTED_FEATURES, URL,
UNSUPPORTED_FEATURES, URL, version version
} from 'pdfjs-lib'; } from 'pdfjs-lib';
import { CursorTool, PDFCursorTools } from './pdf_cursor_tools'; import { CursorTool, PDFCursorTools } from './pdf_cursor_tools';
import { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue'; import { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';
@ -748,7 +748,7 @@ let PDFViewerApplication = {
} }
this.pdfDocument.getData().then(function(data) { 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); downloadManager.download(blob, url, filename);
}).catch(downloadByUrl); // Error occurred, try downloading with the URL. }).catch(downloadByUrl); // Error occurred, try downloading with the URL.
}, },