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

Remove the isRef helper function

This helper function is not really needed, since it's just a wrapper around a simple `instanceof` check, and it only adds unnecessary indirection in the code.
This commit is contained in:
Jonas Jenwald 2022-02-18 12:11:45 +01:00
parent df0aa1a9c4
commit 2cb2f633ac
10 changed files with 55 additions and 67 deletions

View file

@ -19,7 +19,6 @@ import {
isCmd,
isDict,
isName,
isRef,
isRefsEqual,
Name,
Ref,
@ -534,18 +533,6 @@ describe("primitives", function () {
});
});
describe("isRef", function () {
it("handles non-refs", function () {
const nonRef = {};
expect(isRef(nonRef)).toEqual(false);
});
it("handles refs", function () {
const ref = Ref.get(1, 0);
expect(isRef(ref)).toEqual(true);
});
});
describe("isRefsEqual", function () {
it("should handle Refs pointing to the same object", function () {
const ref1 = Ref.get(1, 0);

View file

@ -13,11 +13,11 @@
* limitations under the License.
*/
import { isRef, Ref } from "../../src/core/primitives.js";
import { Page, PDFDocument } from "../../src/core/document.js";
import { assert } from "../../src/shared/util.js";
import { DocStats } from "../../src/core/core_utils.js";
import { isNodeJS } from "../../src/shared/is_node.js";
import { Ref } from "../../src/core/primitives.js";
import { StringStream } from "../../src/core/stream.js";
const TEST_PDFS_PATH = isNodeJS ? "./test/pdfs/" : "../pdfs/";
@ -106,10 +106,10 @@ class XRefMock {
}
fetchIfRef(obj) {
if (!isRef(obj)) {
return obj;
if (obj instanceof Ref) {
return this.fetch(obj);
}
return this.fetch(obj);
return obj;
}
async fetchIfRefAsync(obj) {