Review this AI-generated scanner against its stated task.
Scan at most 10,000 uploaded lines of at most 120 code units each. Treat the supplied project name literally, accept only full IDs with 1–12 ASCII digits, and return matches in numeric order.
JavaScript
export function collectTicketIds(lines, project) {
const ticketPattern = new RegExp(
`^(${project})-(\\d+)$`,
"g",
);
const tickets = [];
for (const line of lines) {
if (!ticketPattern.test(line)) continue;
const match = ticketPattern.exec(line);
tickets.push({
raw: line,
project: match[1],
number: Number(match[2]),
});
}
return tickets.sort(
(left, right) => left.number - right.number,
);
}
generated code is illustrative, not from any one model