File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,16 +28,6 @@ const dataObj = () => ({
2828class 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,10 @@ 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 ) ;
93+ if ( obj . data !== INITIAL_DATA ) {
94+ throw new Error ( `Object already resolved ${ objId } .` ) ;
95+ }
10396 obj . data = data ;
10497 obj . resolve ( ) ;
10598 }
You can’t perform that action at this time.
0 commit comments