Pārlūkot izejas kodu

Rename variable

customisations
alemart 10 mēnešus atpakaļ
vecāks
revīzija
7fce0e1b29
1 mainītis faili ar 11 papildinājumiem un 10 dzēšanām
  1. 11
    10
      src/trackers/image-tracker/reference-image-database.ts

+ 11
- 10
src/trackers/image-tracker/reference-image-database.ts Parādīt failu

@@ -53,8 +53,8 @@ interface ReferenceImageDatabaseEntry
53 53
  */
54 54
 export class ReferenceImageDatabase implements Iterable<ReferenceImage>
55 55
 {
56
-    /** Image database */
57
-    private _database: ReferenceImageDatabaseEntry[];
56
+    /** Entries */
57
+    private _entries: ReferenceImageDatabaseEntry[];
58 58
 
59 59
     /** Maximum number of entries */
60 60
     private _capacity: number;
@@ -73,7 +73,7 @@ export class ReferenceImageDatabase implements Iterable<ReferenceImage>
73 73
     constructor()
74 74
     {
75 75
         this._capacity = DEFAULT_CAPACITY;
76
-        this._database = [];
76
+        this._entries = [];
77 77
         this._locked = false;
78 78
         this._busy = false;
79 79
     }
@@ -83,7 +83,7 @@ export class ReferenceImageDatabase implements Iterable<ReferenceImage>
83 83
      */
84 84
     get count(): number
85 85
     {
86
-        return this._database.length;
86
+        return this._entries.length;
87 87
     }
88 88
 
89 89
     /**
@@ -113,7 +113,7 @@ export class ReferenceImageDatabase implements Iterable<ReferenceImage>
113 113
      */
114 114
     *[Symbol.iterator](): Iterator<ReferenceImage>
115 115
     {
116
-        const ref = this._database.map(entry => entry.referenceImage);
116
+        const ref = this._entries.map(entry => entry.referenceImage);
117 117
         yield* ref;
118 118
     }
119 119
 
@@ -157,14 +157,15 @@ export class ReferenceImageDatabase implements Iterable<ReferenceImage>
157 157
             throw new IllegalArgumentError(`Can't add reference image "${referenceImage.name}" to the database: invalid image`);
158 158
 
159 159
         // check for duplicate names
160
-        if(this._database.find(entry => entry.referenceImage.name === referenceImage.name) !== undefined)
160
+        if(this._entries.find(entry => entry.referenceImage.name === referenceImage.name) !== undefined)
161 161
             throw new IllegalArgumentError(`Can't add reference image "${referenceImage.name}" to the database: found duplicated name`);
162 162
 
163 163
         // load the media and add the reference image to the database
164
+        Utils.log(`Loading reference image "${referenceImage.name}"...`);
164 165
         this._busy = true;
165 166
         return Speedy.load(referenceImage.image).then(media => {
166 167
             this._busy = false;
167
-            this._database.push({
168
+            this._entries.push({
168 169
                 referenceImage: Object.freeze({
169 170
                     ...referenceImage,
170 171
                     name: referenceImage.name || generateUniqueName()
@@ -194,9 +195,9 @@ export class ReferenceImageDatabase implements Iterable<ReferenceImage>
194 195
      */
195 196
     _findMedia(name: string): SpeedyMedia
196 197
     {
197
-        for(let i = 0; i < this._database.length; i++) {
198
-            if(this._database[i].referenceImage.name === name)
199
-                return this._database[i].media;
198
+        for(let i = 0; i < this._entries.length; i++) {
199
+            if(this._entries[i].referenceImage.name === name)
200
+                return this._entries[i].media;
200 201
         }
201 202
 
202 203
         throw new IllegalArgumentError(`Can't find reference image "${name}"`);

Notiek ielāde…
Atcelt
Saglabāt