mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Remove the isArrayBuffer
helper function
This old helper function can now be replaced with `ArrayBuffer.isView()` and/or `instanceof ArrayBuffer` checks, as needed depending on the situation.
This commit is contained in:
parent
a0e2b62245
commit
b37536c38c
4 changed files with 10 additions and 35 deletions
|
@ -24,7 +24,6 @@ import {
|
|||
getVerbosityLevel,
|
||||
info,
|
||||
InvalidPDFException,
|
||||
isArrayBuffer,
|
||||
isNodeJS,
|
||||
MAX_IMAGE_SIZE_TO_CACHE,
|
||||
MissingPDFException,
|
||||
|
@ -103,10 +102,6 @@ const DefaultStandardFontDataFactory =
|
|||
* } TypedArray
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef { TypedArray | ArrayBuffer | Array<number> | string } BinaryData
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} RefProxy
|
||||
* @property {number} num
|
||||
|
@ -118,7 +113,8 @@ const DefaultStandardFontDataFactory =
|
|||
*
|
||||
* @typedef {Object} DocumentInitParameters
|
||||
* @property {string | URL} [url] - The URL of the PDF.
|
||||
* @property {BinaryData} [data] - Binary PDF data.
|
||||
* @property {TypedArray | ArrayBuffer | Array<number> | string} [data] -
|
||||
* Binary PDF data.
|
||||
* Use TypedArrays (Uint8Array) to improve the memory usage. If PDF data is
|
||||
* BASE64-encoded, use `atob()` to convert it to a binary string first.
|
||||
*
|
||||
|
@ -235,7 +231,7 @@ function getDocument(src) {
|
|||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
if (typeof src === "string" || src instanceof URL) {
|
||||
src = { url: src };
|
||||
} else if (isArrayBuffer(src)) {
|
||||
} else if (src instanceof ArrayBuffer || ArrayBuffer.isView(src)) {
|
||||
src = { data: src };
|
||||
}
|
||||
}
|
||||
|
@ -552,7 +548,11 @@ function getDataProp(val) {
|
|||
if (typeof val === "string") {
|
||||
return stringToBytes(val);
|
||||
}
|
||||
if ((typeof val === "object" && !isNaN(val?.length)) || isArrayBuffer(val)) {
|
||||
if (
|
||||
val instanceof ArrayBuffer ||
|
||||
ArrayBuffer.isView(val) ||
|
||||
(typeof val === "object" && !isNaN(val?.length))
|
||||
) {
|
||||
return new Uint8Array(val);
|
||||
}
|
||||
throw new Error(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue