(src, exportName)
| 304 | } |
| 305 | |
| 306 | function findFirstInstantiationOfExportedClass(src, exportName) { |
| 307 | const classIdent = findExportedFactoryVar(src, exportName); |
| 308 | const re = new RegExp(`([A-Za-z0-9_$]+)\\s*=\\s*new\\s+${classIdent}\\s*\\(`, "g"); |
| 309 | const match = re.exec(String(src || "")); |
| 310 | if (!match || typeof match.index !== "number") throw new Error(`failed to locate instantiation: VAR=new ${classIdent}(`); |
| 311 | const openParenIdx = match.index + match[0].lastIndexOf("("); |
| 312 | const closeParenIdx = findMatchingParen(src, openParenIdx); |
| 313 | const terminatorIdx = findStatementTerminatorIndex(src, closeParenIdx + 1, { |
| 314 | allowComma: false, |
| 315 | label: `statement terminator after ${exportName} instantiation` |
| 316 | }); |
| 317 | return { classIdent, varName: match[1], openParenIdx, closeParenIdx, terminatorIdx }; |
| 318 | } |
| 319 | |
| 320 | module.exports = { |
| 321 | ensureMarker, |
no test coverage detected