rdfxml-streaming-parser
Advanced tools
Comparing version 1.1.0 to 1.2.0
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
<a name="v1.2.0"></a> | ||
## [v1.2.0](https://github.com/rdfjs/rdfxml-streaming-parser.js/compare/v1.1.0...v1.2.0) - 2019-01-28 | ||
### Added | ||
* [Implement #import method](https://github.com/rdfjs/rdfxml-streaming-parser.js/commit/9213f6c1b634df839ea970a2f308506bcaa9b4fa) | ||
<a name="v1.1.0"></a> | ||
@@ -5,0 +11,0 @@ ## [v1.1.0](https://github.com/rdfjs/rdfxml-streaming-parser.js/compare/v1.0.1...v1.1.0) - 2018-11-08 |
@@ -5,2 +5,3 @@ /// <reference types="node" /> | ||
import { Transform, TransformCallback } from "stream"; | ||
import EventEmitter = NodeJS.EventEmitter; | ||
export declare class RdfXmlParser extends Transform { | ||
@@ -17,2 +18,3 @@ static readonly MIME_TYPE = "application/rdf+xml"; | ||
static readonly NCNAME_MATCHER: RegExp; | ||
private readonly options; | ||
private readonly dataFactory; | ||
@@ -47,2 +49,8 @@ private readonly baseIRI; | ||
}[]): IExpandedPrefix; | ||
/** | ||
* Parses the given text stream into a quad stream. | ||
* @param {NodeJS.EventEmitter} stream A text stream. | ||
* @return {NodeJS.EventEmitter} A quad stream. | ||
*/ | ||
import(stream: EventEmitter): EventEmitter; | ||
_transform(chunk: any, encoding: string, callback: TransformCallback): void; | ||
@@ -49,0 +57,0 @@ /** |
@@ -13,2 +13,3 @@ "use strict"; | ||
Object.assign(this, args); | ||
this.options = args; | ||
} | ||
@@ -98,2 +99,15 @@ if (!this.dataFactory) { | ||
} | ||
/** | ||
* Parses the given text stream into a quad stream. | ||
* @param {NodeJS.EventEmitter} stream A text stream. | ||
* @return {NodeJS.EventEmitter} A quad stream. | ||
*/ | ||
import(stream) { | ||
const output = new stream_1.PassThrough({ objectMode: true }); | ||
stream.on('error', (error) => parsed.emit('error', error)); | ||
stream.on('data', (data) => output.write(data)); | ||
stream.on('end', () => output.emit('end')); | ||
const parsed = output.pipe(new RdfXmlParser(this.options)); | ||
return parsed; | ||
} | ||
_transform(chunk, encoding, callback) { | ||
@@ -100,0 +114,0 @@ this.saxStream.write(chunk, encoding); |
{ | ||
"name": "rdfxml-streaming-parser", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Streaming RDF/XML parser", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -73,2 +73,18 @@ # RDF/XML Streaming Parser | ||
### Import streams | ||
This parser implements the RDFJS [Sink interface](https://rdf.js.org/#sink-interface), | ||
which makes it possible to alternatively parse streams using the `import` method. | ||
```javascript | ||
const myParser = new RdfXmlParser(); | ||
const myTextStream = fs.createReadStream('myfile.rdf'); | ||
myParser.import(myTextStream) | ||
.on('data', console.log) | ||
.on('error', console.error) | ||
.on('end', () => console.log('All triples were parsed!')); | ||
``` | ||
## Configuration | ||
@@ -75,0 +91,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47830
806
112