hole-in-loop.ts 604 B

1234567891011121314
  1. // A hole in a plain `for` loop (hole-in-for-of covers the for...of form): one step,
  2. // reached per round with that round's bindings, its result carried into the next round's
  3. // `fixes`. The fill is written once and its body runs per reach.
  4. interface Fix {
  5. patch: string;
  6. }
  7. const paths = await files.glob("src/**/*.ts");
  8. const fixes: string[] = [];
  9. for (let i = 0; i < paths.length; i += 1) {
  10. const note = await agent(`审查-${i}`).ask<string>(`审查 ${paths[i]}`);
  11. const fix = await hole<Fix>("决定修法", `第 ${i} 个文件 ${paths[i]}:${note}`);
  12. fixes.push(fix.patch);
  13. }
  14. return fixes;