-
Notifications
You must be signed in to change notification settings - Fork 12
added initial draft for stream interfaces #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,3 +117,56 @@ Triples always have `.graph` set to DefaultGraph. | |
| - `DefaultGraph .defaultGraph()` returns an instance of DefaultGraph. | ||
| - `Triple .triple(Term subject, Term predicate, Term object, [Term graph])` returns a new instance of Triple. | ||
| - `Quad .quad(Term subject, Term predicate, Term object, [Term graph])` returns a new instance of Quad. | ||
|
|
||
| ## Stream interfaces | ||
|
|
||
| Streams are used only in a readable manner. | ||
| This requires only a single queue per stream, which simplifies implementations and doesn't have performance drawbacks, compared to writeable streams. | ||
|
|
||
| ### Stream extends EventEmitter | ||
|
|
||
| **Methods:** | ||
|
|
||
| - `Quad .read()` | ||
| This method pulls a quad out of the internal buffer and returns it. | ||
| If there is no quad available, then it will return null. | ||
|
|
||
| **Events:** | ||
|
|
||
| - `readable` | ||
| When a quad can be read from the stream, it will emit this event. | ||
|
|
||
| - `end` | ||
| This event fires when there will be no more quads to read. | ||
|
|
||
| - `error` | ||
| This event fires if any error occurs. | ||
| The error message is forwarded to the event listener. | ||
|
|
||
| - `data` | ||
| This event is emitted for every quad that can be read from the stream. | ||
| The quad is forwarded to the event listener. | ||
|
|
||
| ### Source | ||
|
|
||
| - `Stream .read([Term|RegExp subject], [Term|RegExp predicate], [Term|RegExp object], [Term|RegExp graph])` | ||
|
||
| Returns a stream that processes all quads matching the pattern. | ||
|
|
||
| ### Sink | ||
|
|
||
| - `undefined .write(Stream stream)` | ||
|
||
| Writes all quads from the stream to the sink. | ||
|
|
||
| ### Store extends Source, Sink | ||
|
|
||
| - `EventEmitter .remove(Stream stream)` | ||
| Removes all streamed quads. | ||
| The `end` and `error` events are used like described in the `Stream` interface. | ||
|
|
||
| - `EventEmitter .removeMatches([Term|RegExp subject], [Term|RegExp predicate], [Term|RegExp object], [Term|RegExp graph])` | ||
| All quads matching the pattern will be removed. | ||
| The `end` and `error` events are used like described in the `Stream` interface. | ||
|
|
||
| - `EventEmitter .deleteGraph(IRI|String graph)` | ||
| Deletes the given named graph. | ||
| The `end` and `error` events are used like described in the `Stream` interface. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about
start?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to
startinstead ofreadableThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readableis an official Node.js event. So let's stay with that standard.