(source, exportName)
| 98 | } |
| 99 | |
| 100 | function extractStringArrayConstant(source, exportName) { |
| 101 | const marker = `export const ${exportName} = [`; |
| 102 | const start = source.indexOf(marker); |
| 103 | assert.notEqual(start, -1, `missing ${exportName} constant`); |
| 104 | const body = source.slice(start + marker.length); |
| 105 | const end = body.indexOf('] as const'); |
| 106 | assert.notEqual(end, -1, `${exportName} must be an as const string array`); |
| 107 | return [...body.slice(0, end).matchAll(/'([^']+)'/g)].map((entry) => entry[1]); |
| 108 | } |
| 109 | |
| 110 | function escapeRegExp(value) { |
| 111 | return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); |
no test coverage detected