Skip to content

Commit e3564de

Browse files
committed
Remove the internal #ensureObj method in the PDFObjects class
With the introduction of `Map.prototype.getOrInsertComputed()` usage this method is no longer necessary, and the code can just be inlined instead.
1 parent cb2ae02 commit e3564de

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

src/display/pdf_objects.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ const dataObj = () => ({
2828
class PDFObjects {
2929
#objs = new Map();
3030

31-
/**
32-
* Ensures there is an object defined for `objId`.
33-
*
34-
* @param {string} objId
35-
* @returns {Object}
36-
*/
37-
#ensureObj(objId) {
38-
return this.#objs.getOrInsertComputed(objId, dataObj);
39-
}
40-
4131
/**
4232
* If called *without* callback, this returns the data of `objId` but the
4333
* object needs to be resolved. If it isn't, this method throws.
@@ -54,7 +44,7 @@ class PDFObjects {
5444
// If there is a callback, then the get can be async and the object is
5545
// not required to be resolved right now.
5646
if (callback) {
57-
const obj = this.#ensureObj(objId);
47+
const obj = this.#objs.getOrInsertComputed(objId, dataObj);
5848
obj.promise.then(() => callback(obj.data));
5949
return null;
6050
}
@@ -99,7 +89,7 @@ class PDFObjects {
9989
* @param {any} [data]
10090
*/
10191
resolve(objId, data = null) {
102-
const obj = this.#ensureObj(objId);
92+
const obj = this.#objs.getOrInsertComputed(objId, dataObj);
10393
if (obj.data !== INITIAL_DATA) {
10494
throw new Error(`Object already resolved ${objId}.`);
10595
}

0 commit comments

Comments
 (0)