| 35 | |
| 36 | // the modules a bundle's entries reach, or why one may reach a validator unseen |
| 37 | export const scanProgram = async ( |
| 38 | key: string, |
| 39 | entries: ScanEntry[], |
| 40 | host: ScanHost |
| 41 | ): Promise<ScannedProgram | string> => { |
| 42 | const steps = programSteps(key, entries, host) |
| 43 | let step = steps.next() |
| 44 | while (!step.done) { |
| 45 | const [kind, requests] = step.value |
| 46 | step = steps.next( |
| 47 | await Promise.all( |
| 48 | kind === "load" ? |
| 49 | requests.map(id => host.load!(id)) |
| 50 | : requests.map(request => host.resolve(...request)) |
| 51 | ) |
| 52 | ) |
| 53 | } |
| 54 | return step.value |
| 55 | } |
| 56 | |
| 57 | // as scanProgram, resolving each specifier as it's read, as --check does |
| 58 | export const scanProgramSync = ( |