mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Tweak handling of the onlyRefs
-option in the BaseLocalCache
class
This commit is contained in:
parent
a936509b77
commit
8ee5acd85d
1 changed files with 6 additions and 5 deletions
|
@ -21,7 +21,9 @@ class BaseLocalCache {
|
|||
if (this.constructor === BaseLocalCache) {
|
||||
unreachable("Cannot initialize BaseLocalCache.");
|
||||
}
|
||||
if (!options || !options.onlyRefs) {
|
||||
this._onlyRefs = (options && options.onlyRefs) === true;
|
||||
|
||||
if (!this._onlyRefs) {
|
||||
this._nameRefMap = new Map();
|
||||
this._imageMap = new Map();
|
||||
}
|
||||
|
@ -29,6 +31,9 @@ class BaseLocalCache {
|
|||
}
|
||||
|
||||
getByName(name) {
|
||||
if (this._onlyRefs) {
|
||||
unreachable("Should not call `getByName` method.");
|
||||
}
|
||||
const ref = this._nameRefMap.get(name);
|
||||
if (ref) {
|
||||
return this.getByRef(ref);
|
||||
|
@ -97,10 +102,6 @@ class LocalFunctionCache extends BaseLocalCache {
|
|||
super({ onlyRefs: true });
|
||||
}
|
||||
|
||||
getByName(name) {
|
||||
unreachable("Should not call `getByName` method.");
|
||||
}
|
||||
|
||||
set(name = null, ref, data) {
|
||||
if (!ref) {
|
||||
throw new Error('LocalFunctionCache.set - expected "ref" argument.');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue