本文整理匯總了TypeScript中n3.StreamParser函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript StreamParser函數的具體用法?TypeScript StreamParser怎麽用?TypeScript StreamParser使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了StreamParser函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test_doc_from_triple_stream_to_rdf_stream
function test_doc_from_triple_stream_to_rdf_stream() {
var streamParser = N3.StreamParser(),
// inputStream = fs.createReadStream('cartoons.ttl'),
streamWriter = N3.StreamWriter({ prefixes: { c: 'http://example.org/cartoons#' } });
// inputStream.pipe(streamParser);
streamParser.pipe(streamWriter);
// streamWriter.pipe(process.stdout);
}
示例2: test_doc_rdf_stream_to_triples_1
function test_doc_rdf_stream_to_triples_1() {
var parser = N3.Parser();
var rdfStream = fs.createReadStream('cartoons.ttl');
parser.parse(rdfStream, console.log);
var streamParser = N3.StreamParser();
var rdfStream = fs.createReadStream('cartoons.ttl');
rdfStream.pipe(streamParser);
streamParser.pipe(new class SlowConsumer extends stream.Writable {
constructor() {
super({ objectMode: true });
this._write = function (triple, encoding, done) {
console.log(triple);
setTimeout(done, 1000);
};
}
});
}
示例3: test_doc_rdf_stream_to_triples_1
function test_doc_rdf_stream_to_triples_1() {
const parser: N3.N3Parser = new N3.Parser();
parser.parse('abc', console.log);
const streamParser: N3.N3StreamParser = N3.StreamParser();
const quad: RDF.Quad = streamParser.read();
const rdfStream = fs.createReadStream('cartoons.ttl');
const pipedStreamParser: N3.N3StreamParser = rdfStream.pipe(streamParser);
streamParser.pipe(new class SlowConsumer extends stream.Writable {
constructor() {
super({ objectMode: true });
this._write = (quad: RDF.Quad, encoding, done) => {
console.log(quad);
setTimeout(done, 1000);
};
}
}());
}
示例4: test_doc_rdf_stream_to_triples_1
function test_doc_rdf_stream_to_triples_1() {
interface QuadBnode extends N3.BaseQuad {
subject: N3.BlankNode;
predicate: N3.BlankNode;
object: N3.BlankNode;
graph: N3.BlankNode;
}
const parser: N3.N3Parser<QuadBnode> = new N3.Parser<QuadBnode>({factory: N3.DataFactory});
parser.parse('abc', console.log);
const streamParser: N3.N3StreamParser = N3.StreamParser();
const quad: RDF.Quad = streamParser.read();
const rdfStream = fs.createReadStream('cartoons.ttl');
const pipedStreamParser: N3.N3StreamParser = rdfStream.pipe(streamParser);
streamParser.pipe(new class SlowConsumer extends stream.Writable {
constructor() {
super({ objectMode: true });
this._write = (quad: RDF.Quad, encoding, done) => {
console.log(quad);
setTimeout(done, 1000);
};
}
}());
}