Which paths does this bounded context picker print?

from AI IDEs
Node 24 beginner 3 min

Which paths does this bounded context picker print?

JavaScript
const files = [
  { path: "src/pay.js", source: "selection", size: 900 },
  { path: "dist/pay.js", source: "index", size: 700 },
  { path: "test/pay.test.js", source: "diagnostic", size: 800 },
];

const rank = { selection: 0, diagnostic: 1, index: 2 };
const picked = files
  .filter((file) => !file.path.startsWith("dist/"))
  .sort((left, right) => rank[left.source] - rank[right.source])
  .slice(0, 2);

console.log(picked.map((file) => file.path).join(", "));
Open in playground
Report an error