sparqlalgebrajs
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -7,3 +7,3 @@ #! /usr/bin/env node | ||
const sparql_1 = require("../lib/sparql"); | ||
const util_1 = require("../test/util"); | ||
const util_1 = require("../lib/util"); | ||
const args = minimist(process.argv.slice(2), { | ||
@@ -10,0 +10,0 @@ boolean: ['q', 'r', 's'], |
@@ -13,2 +13,6 @@ import { Wildcard } from 'sparqljs'; | ||
/** | ||
* Outputs a JSON object corresponding to the input algebra-like. | ||
*/ | ||
static objectify(algebra: any): any; | ||
/** | ||
* Detects all in-scope variables. | ||
@@ -15,0 +19,0 @@ * In practice this means iterating through the entire algebra tree, finding all variables, |
@@ -14,2 +14,37 @@ "use strict"; | ||
/** | ||
* Outputs a JSON object corresponding to the input algebra-like. | ||
*/ | ||
static objectify(algebra) { | ||
if (algebra.termType) { | ||
if (algebra.termType === 'Quad') { | ||
return { | ||
type: 'pattern', | ||
termType: 'Quad', | ||
value: '', | ||
subject: Util.objectify(algebra.subject), | ||
predicate: Util.objectify(algebra.predicate), | ||
object: Util.objectify(algebra.object), | ||
graph: Util.objectify(algebra.graph), | ||
}; | ||
} | ||
else { | ||
let result = { termType: algebra.termType, value: algebra.value }; | ||
if (algebra.language) | ||
result.language = algebra.language; | ||
if (algebra.datatype) | ||
result.datatype = Util.objectify(algebra.datatype); | ||
return result; | ||
} | ||
} | ||
if (Array.isArray(algebra)) | ||
return algebra.map(e => Util.objectify(e)); | ||
if (algebra === Object(algebra)) { | ||
let result = {}; | ||
for (let key of Object.keys(algebra)) | ||
result[key] = Util.objectify(algebra[key]); | ||
return result; | ||
} | ||
return algebra; | ||
} | ||
/** | ||
* Detects all in-scope variables. | ||
@@ -16,0 +51,0 @@ * In practice this means iterating through the entire algebra tree, finding all variables, |
{ | ||
"name": "sparqlalgebrajs", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Convert SPARQL to SPARQL algebra", | ||
@@ -26,5 +26,5 @@ "author": "Joachim Van Herwegen", | ||
"@types/chai": "^4.2.18", | ||
"@types/mocha": "^8.2.2", | ||
"@types/mocha": "^9.0.0", | ||
"chai": "^4.3.4", | ||
"mocha": "^8.4.0", | ||
"mocha": "^9.0.3", | ||
"nyc": "^15.1.0", | ||
@@ -31,0 +31,0 @@ "pre-commit": "^1.2.2", |
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
111801
2608