sparqljson-parse
Advanced tools
Comparing version 2.0.0 to 2.0.1
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
<a name="v2.0.1"></a> | ||
## [v2.0.1](https://github.com/rubensworks/sparqljson-parse.js/compare/v2.0.0...v2.0.1) - 2022-07-15 | ||
### Fixed | ||
* [Ensure variables or error event is emitted](https://github.com/rubensworks/sparqljson-parse.js/commit/40a86691c9096a75ef3218a928e73bc0ea68cefb) | ||
<a name="v2.0.0"></a> | ||
@@ -5,0 +11,0 @@ ## [v2.0.0](https://github.com/rubensworks/sparqljson-parse.js/compare/v1.7.0...v2.0.0) - 2022-07-14 |
@@ -40,6 +40,12 @@ "use strict"; | ||
jsonParser.onError = errorListener; | ||
let variablesFound = false; | ||
let resultsFound = false; | ||
jsonParser.onValue = (value) => { | ||
if (jsonParser.key === "vars" && jsonParser.stack.length === 2 && jsonParser.stack[1].key === 'head') { | ||
resultStream.emit('variables', value.map((v) => this.dataFactory.variable(v))); | ||
variablesFound = true; | ||
} | ||
else if (jsonParser.key === "results" && jsonParser.stack.length === 1) { | ||
resultsFound = true; | ||
} | ||
else if (typeof jsonParser.key === 'number' && jsonParser.stack.length === 3 && jsonParser.stack[1].key === 'results' && jsonParser.stack[2].key === 'bindings') { | ||
@@ -50,2 +56,10 @@ resultStream.push(this.parseJsonBindings(value)); | ||
const resultStream = sparqlResponseStream | ||
.on("end", _ => { | ||
if (!resultsFound) { | ||
resultStream.emit("error", new Error("No valid SPARQL query results were found.")); | ||
} | ||
else if (!variablesFound) { | ||
resultStream.emit('variables', []); | ||
} | ||
}) | ||
.pipe(new readable_stream_1.Transform({ | ||
@@ -52,0 +66,0 @@ objectMode: true, |
{ | ||
"name": "sparqljson-parse", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Parses SPARQL JSON query results", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
22289
255