wikibase-sdk
Advanced tools
Comparing version 10.0.0 to 10.0.1
import type { SimplifiedSparqlResults, SparqlResults, SimplifiedSparqlValueGroup, SparqlValueRaw } from '../types/sparql.js'; | ||
export declare function simplifySparqlResults(input: SparqlResults | string): (Record<string, SparqlValueRaw> & Record<string, SimplifiedSparqlValueGroup>)[]; | ||
export declare function minimizeSimplifiedSparqlResults(simplifySparqlResults: SimplifiedSparqlResults): SparqlValueRaw[]; | ||
export declare function minimizeSimplifiedSparqlResults(simplifySparqlResults: SimplifiedSparqlResults): SimplifiedSparqlResults | SparqlValueRaw[]; | ||
//# sourceMappingURL=simplify_sparql_results.d.ts.map |
@@ -12,11 +12,11 @@ export function simplifySparqlResults(input) { | ||
export function minimizeSimplifiedSparqlResults(simplifySparqlResults) { | ||
return simplifySparqlResults | ||
.map(simplifySparqlResult => { | ||
const values = Object.values(simplifySparqlResult); | ||
if (values.length > 1) | ||
throw new Error('too many variables: SPARQL result can not be minimzed'); | ||
return values[0]; | ||
}) | ||
// filtering-out bnodes | ||
.filter((result) => result != null); | ||
// filtering-out bnodes | ||
simplifySparqlResults = simplifySparqlResults.filter(result => Object.keys(result).length > 0); | ||
const canBeMinimized = simplifySparqlResults.every(result => Object.keys(result).length === 1); | ||
if (canBeMinimized) { | ||
return simplifySparqlResults.map(result => Object.values(result)[0]); | ||
} | ||
else { | ||
return simplifySparqlResults; | ||
} | ||
} | ||
@@ -23,0 +23,0 @@ function parseValue(valueObj) { |
{ | ||
"name": "wikibase-sdk", | ||
"version": "10.0.0", | ||
"version": "10.0.1", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "utils functions to query a Wikibase instance and simplify its results", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
325886