* @param {string} context context * @param {string[]} possibleRequests possible requests * @returns {Promise } resolved requests
(context, possibleRequests)
| 196 | * @returns {Promise<string>} resolved requests |
| 197 | */ |
| 198 | async resolveRequests(context, possibleRequests) { |
| 199 | if (possibleRequests.length === 0) { |
| 200 | throw new Error("No possible requests to resolve"); |
| 201 | } |
| 202 | |
| 203 | let result; |
| 204 | |
| 205 | try { |
| 206 | result = await resolve(context, possibleRequests[0]); |
| 207 | } catch (error) { |
| 208 | const [, ...tailPossibleRequests] = possibleRequests; |
| 209 | |
| 210 | if (tailPossibleRequests.length === 0) { |
| 211 | throw error; |
| 212 | } |
| 213 | |
| 214 | result = await this.resolveRequests(context, tailPossibleRequests); |
| 215 | } |
| 216 | |
| 217 | return result; |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * @param {string} filename filename |