1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Introduce a helper function for clamping a value to a range

Currently we have a number of spots in the code-base where we need to clamp a value to a [min, max] range. This is either implemented using `Math.min`/`Math.max` or with a local helper function, which leads to some unnecessary duplication.

Hence this patch adds and re-uses a single helper function for this, which we'll hopefully be able to remove in the future once https://github.com/tc39/proposal-math-clamp/ becomes generally available.
This commit is contained in:
Jonas Jenwald 2025-03-06 12:57:14 +01:00
parent dea35aed4a
commit 07bbbf75a5
12 changed files with 57 additions and 68 deletions

View file

@ -24,6 +24,7 @@ import {
getUuid,
ImageKind,
InvalidPDFException,
MathClamp,
normalizeUnicode,
OPS,
PasswordResponses,
@ -96,6 +97,7 @@ const expectedAPI = Object.freeze({
isDataScheme,
isPdfFile,
isValidExplicitDest,
MathClamp,
noContextMenu,
normalizeUnicode,
OPS,