Skip to content

CONSUME-AS-DATA-05: Target rows with column / find / rowPos

TableView offers column(name), find(pred), and rowPos(i) for column slices, predicate lookups, and per-row source positions.

Builds on: CONSUME-AS-DATA-04: Iterate a TableView’s typed rows

A TypeScript program against the library API; inline comments show the resulting values and behavior.

const files = doc.body.files;
files.column("File"); // ["grammar.ts", "leaves.ts", "legacy.ts"]
files.find(r => r.Kind === "delete")?.File; // "legacy.ts" — typed predicate
files.find((_r, i) => i === 0)?.File; // "grammar.ts" — index available too
files.rowPos(2); // { line: 7, col: 1 } — that row's SourcePos
  • TableView.column(name)
  • .find(pred) with row+index
  • .rowPos(i) returning SourcePos