| 139 | } |
| 140 | |
| 141 | function getText(text) { |
| 142 | const record = textCache.get(text); |
| 143 | if (record === undefined) { |
| 144 | const thenable = { |
| 145 | pings: [], |
| 146 | then(resolve) { |
| 147 | if (newRecord.status === class="st">'pending') { |
| 148 | thenable.pings.push(resolve); |
| 149 | } else { |
| 150 | Promise.resolve().then(() => resolve(newRecord.value)); |
| 151 | } |
| 152 | }, |
| 153 | }; |
| 154 | const newRecord = { |
| 155 | status: class="st">'pending', |
| 156 | value: thenable, |
| 157 | }; |
| 158 | textCache.set(text, newRecord); |
| 159 | return thenable; |
| 160 | } else { |
| 161 | switch (record.status) { |
| 162 | case class="st">'pending': |
| 163 | return record.value; |
| 164 | case class="st">'rejected': |
| 165 | return Promise.reject(record.value); |
| 166 | case class="st">'resolved': |
| 167 | return Promise.resolve(record.value); |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | function Text({text}) { |
| 173 | Scheduler.log(text); |