Conversation
jeswr
commented
Feb 12, 2026
- BREAKING CHANGE: remove match methods from DatasetCoreBase
- Refactor subjectsOf and objectsOf methods to use toTerm for improved clarity
There was a problem hiding this comment.
Pull request overview
This PR updates the dataset wrapper API by removing the older matchSubjectsOf/matchObjectsOf helpers and refactoring subjectsOf/objectsOf to build RDF/JS Terms via a shared toTerm helper, plus updating docs/tests to the new argument order.
Changes:
- Remove
matchSubjectsOf/matchObjectsOfand implement filtering directly insubjectsOf/objectsOf. - Refactor term construction through
toTerm(...)for predicate/object/graph (and subject forobjectsOf). - Update usage in unit model wrapper and README examples to match the new
subjectsOfsignature.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/unit/model/ParentDataset.ts | Updates subjectsOf(...) call site to the new argument order. |
| src/DatasetWrapper.ts | Removes match helper methods and refactors subjectsOf/objectsOf to use toTerm. |
| README.md | Updates example to the new subjectsOf(TermWrapperCtor, predicate) call style. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
langsamu
left a comment
There was a problem hiding this comment.
The current design was intentional: On one hand,
- to facilitate the full power of RDF/JS
matchand on the other - to expose a readable API.
Match
The RDF/JS DatasetCore.match is the primary interaction point with statements. By its polymorphic versatility, it facilitates all possible graph patterns. Namely, all four arguments of match are optional (Term | undefined).
I would like the library to make this pattern available to inheritors of DatasetWrapper.
Readability
The idea behind the terser select/project utility method name signatures is to reflect something akin to these statements:
Give me the subjects of the predicate p wrapped in (projected onto instances of) c.
My best approximation of the above is a line like
return this.subjectsOf(Vocabulary.hasChild, Parent)The change proposed here is indeed a simplification if we only consider the code implemented to date.
But if you consider plans for the evolution of the API (which are, admittedly, undocumented for now) then I would rather keep things as they are.
This was more a feature addition than anything; in particular to enable matching over Literals and Blank Nodes in the subject/object position (per #12). Granted, we can keep this as
I don't understand - the following are equivalent in the JS world: return this.subjectsOf(Parent, Vocabulary.hasChild)return this.subjectsOf(Parent, Vocabulary.hasChild, undefined, undefined)Do you care about the order of |
|
RE RE readability: I would like two things:
This is why I'm trying to keep the verbose method in and also to have a terse utility signature in addition to that. Specifically putting the predicate first was an explicit request for readability from my first reviewer, Matthieu. |