8
8
} from "@comunica/bus-rdf-parse" ;
9
9
import { ActionContext , Actor , Mediator } from "@comunica/core" ;
10
10
import * as RDF from "rdf-js" ;
11
- import { Readable } from "stream" ;
11
+ import { Readable , PassThrough } from "stream" ;
12
12
13
13
/**
14
14
* An RdfParser can parse any RDF serialization, based on a given content type.
@@ -81,10 +81,7 @@ export class RdfParser<Q extends RDF.BaseQuad = RDF.Quad> {
81
81
}
82
82
83
83
// Create a new readable
84
- const readable = new Readable ( { objectMode : true } ) ;
85
- readable . _read = ( ) => {
86
- return ;
87
- } ;
84
+ const readable = new PassThrough ( { objectMode : true } ) ;
88
85
89
86
// Delegate parsing to the mediator
90
87
this . mediatorRdfParseHandle . mediate ( {
@@ -93,10 +90,9 @@ export class RdfParser<Q extends RDF.BaseQuad = RDF.Quad> {
93
90
handleMediaType : contentType ,
94
91
} )
95
92
. then ( ( output ) => {
96
- const quads : RDF . Stream = output . handle . quads ;
93
+ const quads = < Readable > output . handle . quads ;
97
94
quads . on ( 'error' , ( e ) => readable . emit ( 'error' , e ) ) ;
98
- quads . on ( 'data' , ( quad ) => readable . push ( quad ) ) ;
99
- quads . on ( 'end' , ( ) => readable . push ( null ) ) ;
95
+ quads . pipe ( readable ) ;
100
96
} )
101
97
. catch ( ( e ) => readable . emit ( 'error' , e ) ) ;
102
98
0 commit comments