UNPKG

@tpluscode/sparql-builder

Version:

Simple JS library to build SPARQL queries

14 lines (13 loc) 345 B
import { sparql } from '@tpluscode/rdf-string'; export function UNION(...[first, ...rest]) { if (rest.length === 0) { return sparql `${first}` || ''; } return rest.reduce((previousValue, currentValue) => { return sparql `${previousValue} UNION { ${currentValue} }`; }, sparql `{ ${first} }`); }