1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 23:58:07 +02:00

Add a size getter, to Dict instances, to provide an easier way of checking the number of entries

This removes the need to manually call `Dict.getKeys()` and check its length.
This commit is contained in:
Jonas Jenwald 2020-07-16 11:57:50 +02:00
parent e63d1ebff5
commit 6381b5b08f
3 changed files with 16 additions and 1 deletions

View file

@ -117,6 +117,17 @@ describe("primitives", function () {
expect(dict.xref).toEqual(xref);
});
it("should return correct size", function () {
const dict = new Dict(null);
expect(dict.size).toEqual(0);
dict.set("Type", Name.get("Page"));
expect(dict.size).toEqual(1);
dict.set("Contents", Ref.get(10, 0));
expect(dict.size).toEqual(2);
});
it("should return invalid values for unknown keys", function () {
checkInvalidHasValues(emptyDict);
checkInvalidKeyValues(emptyDict);