1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Rename the isSpace helper function to isWhiteSpace

Trying to enable the ESLint rule `no-shadow`, against the `master` branch, would result in a fair number of errors in the `Glyph` class in `src/core/fonts.js`.
Since the glyphs are exposed through the API, we can't very well change the `isSpace` property on `Glyph` instances. Thus the best approach seems, at least to me, to simply rename the `isSpace` helper function to `isWhiteSpace` which shouldn't cause any issues given that it's only used in the `src/core/` folder.
This commit is contained in:
Jonas Jenwald 2020-02-10 09:38:57 +01:00
parent e4758beaaa
commit c5f67300e9
8 changed files with 32 additions and 28 deletions

View file

@ -43,7 +43,7 @@ import {
Name,
Ref,
} from "./primitives.js";
import { isSpace, MissingDataException } from "./core_utils.js";
import { isWhiteSpace, MissingDataException } from "./core_utils.js";
import { CCITTFaxStream } from "./ccitt_stream.js";
import { Jbig2Stream } from "./jbig2_stream.js";
import { JpegStream } from "./jpeg_stream.js";
@ -270,7 +270,7 @@ class Parser {
// Ensure that we don't accidentally truncate the inline image, when the
// data is immediately followed by the "EI" marker (fixes issue10388.pdf).
if (!isSpace(ch)) {
if (!isWhiteSpace(ch)) {
endOffset--;
}
return stream.pos - endOffset - startPos;
@ -394,7 +394,7 @@ class Parser {
ch = stream.peekByte();
// Handle corrupt PDF documents which contains whitespace "inside" of
// the EOD marker (fixes issue10614.pdf).
while (isSpace(ch)) {
while (isWhiteSpace(ch)) {
stream.skip();
ch = stream.peekByte();
}
@ -640,7 +640,7 @@ class Parser {
// Ensure that the byte immediately following the truncated
// endstream command is a space, to prevent false positives.
const lastByte = stream.peekBytes(end + 1)[end];
if (!isSpace(lastByte)) {
if (!isWhiteSpace(lastByte)) {
break;
}
info(
@ -886,7 +886,7 @@ class Lexer {
if (
divideBy === 10 &&
sign === 0 &&
(isSpace(ch) || ch === /* EOF = */ -1)
(isWhiteSpace(ch) || ch === /* EOF = */ -1)
) {
// This is consistent with Adobe Reader (fixes issue9252.pdf).
warn("Lexer.getNumber - treating a single decimal point as zero.");