Merge pull request #21624 from Snuffleupagus/rm-objectSize

Remove the `objectSize` helper function
This commit is contained in:
Tim van der Meij 2026-07-24 20:31:54 +02:00 committed by GitHub
commit 586c3095d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 7 additions and 14 deletions

View File

@ -18,7 +18,6 @@ import {
assert, assert,
BaseException, BaseException,
makeArr, makeArr,
objectSize,
Util, Util,
warn, warn,
} from "../shared/util.js"; } from "../shared/util.js";
@ -491,7 +490,7 @@ function collectActions(xref, dict, eventType) {
actions.Action = list; actions.Action = list;
} }
} }
return objectSize(actions) > 0 ? actions : null; return Object.keys(actions).length ? actions : null;
} }
const XMLEntities = { const XMLEntities = {

View File

@ -21,7 +21,6 @@ import {
InvalidPDFException, InvalidPDFException,
isArrayEqual, isArrayEqual,
makeArr, makeArr,
objectSize,
PageActionEventType, PageActionEventType,
RenderingIntentFlag, RenderingIntentFlag,
shadow, shadow,
@ -1986,7 +1985,7 @@ class PDFDocument {
await Promise.all(allPromises); await Promise.all(allPromises);
return { return {
allFields: objectSize(allFields) > 0 ? allFields : null, allFields: Object.keys(allFields).length ? allFields : null,
orphanFields, orphanFields,
}; };
}); });

View File

@ -615,10 +615,6 @@ function stringToBytes(str) {
return bytes; return bytes;
} }
function objectSize(obj) {
return Object.keys(obj).length;
}
class FeatureTest { class FeatureTest {
static get isLittleEndian() { static get isLittleEndian() {
const buffer8 = new Uint8Array(4); const buffer8 = new Uint8Array(4);
@ -1209,7 +1205,6 @@ export {
makeSet, makeSet,
MeshFigureType, MeshFigureType,
normalizeUnicode, normalizeUnicode,
objectSize,
OPS, OPS,
PageActionEventType, PageActionEventType,
PasswordException, PasswordException,

View File

@ -22,7 +22,6 @@ import {
ImageKind, ImageKind,
InvalidPDFException, InvalidPDFException,
isNodeJS, isNodeJS,
objectSize,
OPS, OPS,
PasswordException, PasswordException,
PasswordResponses, PasswordResponses,
@ -4143,7 +4142,7 @@ describe("api", function () {
const { items, styles, lang } = await page.getTextContent(); const { items, styles, lang } = await page.getTextContent();
expect(items.length).toEqual(15); expect(items.length).toEqual(15);
expect(objectSize(styles)).toEqual(5); expect(Object.keys(styles).length).toEqual(5);
expect(lang).toEqual("en"); expect(lang).toEqual("en");
const text = mergeText(items); const text = mergeText(items);

View File

@ -15,7 +15,6 @@
import { AppOptions, OptionKind } from "../../web/app_options.js"; import { AppOptions, OptionKind } from "../../web/app_options.js";
import { BasePreferences } from "../../web/preferences.js"; import { BasePreferences } from "../../web/preferences.js";
import { objectSize } from "../../src/shared/util.js";
describe("AppOptions", function () { describe("AppOptions", function () {
it("checks that getAll returns data, for every OptionKind", function () { it("checks that getAll returns data, for every OptionKind", function () {
@ -32,7 +31,7 @@ describe("AppOptions", function () {
expect(typeof kind).toEqual("number"); expect(typeof kind).toEqual("number");
const options = AppOptions.getAll(kind); const options = AppOptions.getAll(kind);
expect(objectSize(options)).toBeGreaterThan(0); expect(Object.keys(options).length).toBeGreaterThan(0);
} }
}); });
@ -43,7 +42,9 @@ describe("AppOptions", function () {
const MAX_NUMBER_OF_PREFS = 50; const MAX_NUMBER_OF_PREFS = 50;
const options = AppOptions.getAll(OptionKind.PREFERENCE); const options = AppOptions.getAll(OptionKind.PREFERENCE);
expect(objectSize(options)).toBeLessThanOrEqual(MAX_NUMBER_OF_PREFS); expect(Object.keys(options).length).toBeLessThanOrEqual(
MAX_NUMBER_OF_PREFS
);
}); });
}); });