1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

[api-minor] Move removeNullCharacters into the viewer

This helper function has never been used in e.g. the worker-thread, hence its placement in `src/shared/util.js` led to a *small* amount of unnecessary duplication.
After the previous patches this helper function is now *only* used in the viewer, hence it no longer seems necessary to expose it through the official API.

*Please note:* It seems somewhat unlikely that third-party users were relying *directly* on this helper function, which is why it's not being exported as part of the viewer components. (If necessary, we can always change this later on.)
This commit is contained in:
Jonas Jenwald 2022-01-03 14:11:12 +01:00
parent 00aa9811e6
commit 7b8794b37e
7 changed files with 46 additions and 48 deletions

View file

@ -30,7 +30,6 @@ import {
OPS,
PasswordResponses,
PermissionFlag,
removeNullCharacters,
shadow,
UnexpectedResponseException,
UNSUPPORTED_FEATURES,
@ -129,7 +128,6 @@ export {
PDFWorker,
PermissionFlag,
PixelsPerInch,
removeNullCharacters,
RenderingCancelledException,
renderTextLayer,
shadow,

View file

@ -575,23 +575,6 @@ class AbortException extends BaseException {
}
}
const NullCharactersRegExp = /\x00+/g;
const InvisibleCharactersRegExp = /[\x01-\x1F]/g;
/**
* @param {string} str
*/
function removeNullCharacters(str, replaceInvisible = false) {
if (typeof str !== "string") {
warn("The argument for removeNullCharacters must be a string.");
return str;
}
if (replaceInvisible) {
str = str.replace(InvisibleCharactersRegExp, " ");
}
return str.replace(NullCharactersRegExp, "");
}
function bytesToString(bytes) {
assert(
bytes !== null && typeof bytes === "object" && bytes.length !== undefined,
@ -1185,7 +1168,6 @@ export {
PasswordException,
PasswordResponses,
PermissionFlag,
removeNullCharacters,
RenderingIntentFlag,
setVerbosityLevel,
shadow,