MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / parsePageRange

Function parsePageRange

src/tools/filesystem/pdf-read.ts:220–236  ·  view source on GitHub ↗
(spec: string, total: number)

Source from the content-addressed store, hash-verified

218}
219
220function parsePageRange(spec: string, total: number): Set<number> {
221 const wanted = new Set<number>();
222 for (const part of spec.split(/[,\s]+/).filter(Boolean)) {
223 const dash = part.indexOf('-');
224 if (dash !== -1) {
225 const a = parseInt(part.slice(0, dash), 10);
226 const b = parseInt(part.slice(dash + 1), 10);
227 if (!isNaN(a) && !isNaN(b)) {
228 for (let i = a; i <= b && i <= total; i++) wanted.add(i);
229 }
230 } else {
231 const n = parseInt(part, 10);
232 if (!isNaN(n) && n >= 1 && n <= total) wanted.add(n);
233 }
234 }
235 return wanted;
236}
237
238export class PdfReadTool extends Tool<z.infer<typeof PdfReadArgs>> {
239 name = 'pdf_read';

Callers 1

executeMethod · 0.85

Calls 1

addMethod · 0.80

Tested by

no test coverage detected