feat(async): AsyncDatasetWrapper query helpers#97
Draft
jeswr wants to merge 1 commit into
Draft
Conversation
Adds an asynchronous counterpart of DatasetWrapper for datasets whose contents cannot be read synchronously (disk- or remote-backed stores): - src/async/AsyncDatasetWrapper.ts implements the proposed RDF/JS AsyncDatasetCore interface by delegation (Promise-based size/add/ delete/has, for-await iteration, lazy match views) and provides the same protected query helpers as DatasetWrapper - subjectsOf, objectsOf, instancesOf, matchSubjectsOf, matchObjectsOf - returning AsyncIterable<T> built from an IAsyncTermWrapperConstructor. - src/async/type/IAsyncTermWrapperConstructor.ts mirrors ITermWrapperConstructor for the asynchronous surface. - Synchronous DatasetCore sources (instance, promise or lazy thunk) are adapted automatically via the @jeswr/async-dataset foundation package, so existing sync stores (e.g. an n3 Store) work unchanged. - Ports the async_dataset_wrapper.test.ts slice with AsyncParent/ AsyncChild/AsyncParentDataset fixture models. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 6, 2026
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Adds an asynchronous counterpart of
DatasetWrapperfor datasets whose contents cannot be read synchronously — for example disk- or remote-backed stores:AsyncDatasetWrapper(src/async/AsyncDatasetWrapper.ts) implements the proposed RDF/JSAsyncDatasetCoreinterface by delegation — Promise-basedsize/add/delete/has,for awaititeration, and (potentially lazily evaluated)matchviews — and offers the same protected query helpers asDatasetWrapper:subjectsOf,objectsOf,instancesOf,matchSubjectsOf,matchObjectsOf, each returning anAsyncIterable<T>of mapping-class instances.IAsyncTermWrapperConstructor(src/async/type/IAsyncTermWrapperConstructor.ts) mirrorsITermWrapperConstructorfor the asynchronous surface:new (term, dataset: AsyncDatasetCore, factory) => T.AsyncDatasetCoreor any synchronousDatasetCoresource (an instance, a promise of one, or a lazy thunk). Synchronous sources are adapted automatically via the@jeswr/async-datasetfoundation package (this repo's first runtime dependency — a deliberate, visible decision), so existing sync stores such as an n3Storework unchanged.@rdfjs/typesdevDependency moves tojeswr/types#async-eventful-dataset-types, which adds the proposedAsyncDatasetCore/AsyncDatasetinterfaces (see feat: add AsyncDataset and EventfulDataset interface variants jeswr/types#2 for the upstream type proposal).async_dataset_wrapper.test.tsslice withAsyncParent/AsyncChild/AsyncParentDatasetfixture models covering all five helpers, both wrapping paths (already-async and sync-backed, including a lazy thunk), iteration,size,match, and theadd/has/deleteround trip.Scope
Supersedes the
AsyncDatasetWrapperslice of #73 (dataset-side async concern) — deliberately minus the notification surface (on/off), the default-graph-onlyTriplerestriction, and thedatasetFactoryconstructor parameter from that omnibus branch, which belong to separate slices. The term-side async concern (AsyncTermWrapperand async mappings) is a separate upcoming slice that builds on theIAsyncTermWrapperConstructortype introduced here; the test models in this PR intentionally use plain hand-rolled classes so this slice stands alone.No issue is closed by this PR.
Checks
npx tsc,npm test(133 tests, 0 fail; new code at ~99% line / 100% branch coverage),npx typedoc(no new warnings) andnpm audit --omit=dev --audit-level=moderateall pass locally on Node 24.