From 25bac064d88c0b14653c62a619e52c8e0d4c705e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 1 Jul 2023 10:29:21 +0200 Subject: [PATCH] [api-minor] Stop "supporting" binary data provided as `Buffer` in Node.js environments (PR 16055 follow-up) Given that the PDF.js library has never officially supported/documented that binary data can be provided as a `Buffer`, and that it's been explicitly deprecated in *four* releases, it seems reasonable that we outright reject such data instead (to reduce the amount of Node.js specific code-paths). --- src/display/api.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index b9abc3bea..79e22de9e 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -549,10 +549,9 @@ function getDataProp(val) { typeof Buffer !== "undefined" && // eslint-disable-line no-undef val instanceof Buffer // eslint-disable-line no-undef ) { - deprecated( + throw new Error( "Please provide binary data as `Uint8Array`, rather than `Buffer`." ); - return new Uint8Array(val); } if (val instanceof Uint8Array && val.byteLength === val.buffer.byteLength) { // Use the data as-is when it's already a Uint8Array that completely