How to use the ldflex.SparqlHandler.prototype function in ldflex

To help you get started, we’ve selected a few ldflex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github solid / query-ldflex / src / util.js View on Github external
import { SparqlHandler } from 'ldflex';

export const { termToString } = SparqlHandler.prototype;

export function replaceVariables(template, terms) {
  for (const name in terms)
    template = template.replace(new RegExp(`_:${name}`, 'g'), termToString(terms[name]));
  return template;
}

// Imitate Comunica's response for bindings as a Immutable.js object.
export function createBindings(...items) {
  return {
    size: items.length,
    values: () => ({
      next: () => ({ value: items.shift() }),
    }),
  };
}

ldflex

A JavaScript DSL for querying Linked Data on the Web

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis