mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +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:
parent
e63d1ebff5
commit
6381b5b08f
3 changed files with 16 additions and 1 deletions
|
@ -551,7 +551,7 @@ class PDFDocument {
|
|||
// Check if a Collection dictionary is present in the document.
|
||||
try {
|
||||
const collection = this.catalog.catDict.get("Collection");
|
||||
if (isDict(collection) && collection.getKeys().length > 0) {
|
||||
if (isDict(collection) && collection.size > 0) {
|
||||
this.collection = collection;
|
||||
}
|
||||
} catch (ex) {
|
||||
|
|
|
@ -85,6 +85,10 @@ var Dict = (function DictClosure() {
|
|||
this.xref = newXref;
|
||||
},
|
||||
|
||||
get size() {
|
||||
return Object.keys(this._map).length;
|
||||
},
|
||||
|
||||
// automatically dereferences Ref objects
|
||||
get(key1, key2, key3) {
|
||||
let value = this._map[key1];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue