mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Reduce duplication for reference tests with an annotationStorage
entry
Currently we duplicate the same code more than once in the `test/driver.js` file, which we can avoid by adding a new `AnnotationStorage` helper method instead.
This commit is contained in:
parent
f66cbb0b5e
commit
8026ed6b0a
2 changed files with 24 additions and 22 deletions
|
@ -120,10 +120,22 @@ class AnnotationStorage {
|
|||
return this.#storage.has(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Object | null}
|
||||
*/
|
||||
getAll() {
|
||||
return this.#storage.size > 0 ? objectFromMap(this.#storage) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} obj
|
||||
*/
|
||||
setAll(obj) {
|
||||
for (const [key, val] of Object.entries(obj)) {
|
||||
this.setValue(key, val);
|
||||
}
|
||||
}
|
||||
|
||||
get size() {
|
||||
return this.#storage.size;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue