1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-29 15:47:57 +02:00

Stop using the PRODUCTION build-target in the JavaScript code

This *special* build-target is very old, and was introduced with the first pre-processor that only uses comments to enable/disable code.
When the new pre-processor was added `PRODUCTION` effectively became redundant, at least in JavaScript code, since `typeof PDFJSDev === "undefined"` checks now do the same thing.

This patch proposes that we remove `PRODUCTION` from the JavaScript code, since that simplifies the conditions and thus improves readability in many cases.
*Please note:* There's not, nor has there ever been, any gulp-task that set `PRODUCTION = false` during building.
This commit is contained in:
Jonas Jenwald 2023-03-18 12:09:25 +01:00
parent 3e08eee511
commit 804aa896a7
29 changed files with 88 additions and 267 deletions

View file

@ -316,10 +316,7 @@ function int32(b0, b1, b2, b3) {
}
function string16(value) {
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
assert(
typeof value === "number" && Math.abs(value) < 2 ** 16,
`string16: Unexpected input "${value}".`
@ -329,10 +326,7 @@ function string16(value) {
}
function safeString16(value) {
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
assert(
typeof value === "number" && !Number.isNaN(value),
`safeString16: Unexpected input "${value}".`