mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-12 18:15:48 +02:00
Replace a couple of indexOf calls with startsWith
These cases weren't detected/fixed by the following ESLint plugin rule; see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-starts-ends-with.md Additionally, replace the `if` with a ternary statement in the `external/builder/builder.mjs` file since this patch touches that code anyway.
This commit is contained in:
parent
8bc2fe68e5
commit
f0822e527e
13
external/builder/builder.mjs
vendored
13
external/builder/builder.mjs
vendored
@ -113,16 +113,9 @@ function preprocess(inFilename, outFilename, defines) {
|
|||||||
const realPath = fs.realpathSync(inFilename);
|
const realPath = fs.realpathSync(inFilename);
|
||||||
const dir = path.dirname(realPath);
|
const dir = path.dirname(realPath);
|
||||||
try {
|
try {
|
||||||
let fullpath;
|
const fullpath = file.startsWith("$ROOT/")
|
||||||
if (file.indexOf("$ROOT/") === 0) {
|
? path.join(__dirname, "../..", file.substring("$ROOT/".length))
|
||||||
fullpath = path.join(
|
: path.join(dir, file);
|
||||||
__dirname,
|
|
||||||
"../..",
|
|
||||||
file.substring("$ROOT/".length)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
fullpath = path.join(dir, file);
|
|
||||||
}
|
|
||||||
preprocess(fullpath, writeLine, defines);
|
preprocess(fullpath, writeLine, defines);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.code === "ENOENT") {
|
if (e.code === "ENOENT") {
|
||||||
|
|||||||
2
external/cmapscompress/compress.mjs
vendored
2
external/cmapscompress/compress.mjs
vendored
@ -386,7 +386,7 @@ function writeNumber(n) {
|
|||||||
if (buffer > 0) {
|
if (buffer > 0) {
|
||||||
s = writeByte((buffer & 0x7f) | (s.length > 0 ? 0x80 : 0)) + s;
|
s = writeByte((buffer & 0x7f) | (s.length > 0 ? 0x80 : 0)) + s;
|
||||||
}
|
}
|
||||||
while (s.indexOf("80") === 0) {
|
while (s.startsWith("80")) {
|
||||||
s = s.substring(2);
|
s = s.substring(2);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user