How to use the @rdfjs/data-model.defaultGraph function in @rdfjs/data-model

To help you get started, we’ve selected a few @rdfjs/data-model 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 comunica / comunica / packages / actor-rdf-parse-jsonld / lib / ActorRdfParseJsonLd.ts View on Github external
public static mapTerm(term: any): RDF.Term {
    switch (term.termType) {
    case 'NamedNode':
      return namedNode(term.value);
    case 'BlankNode':
      return blankNode(term.value.substr(2)); // Remove the '_:' prefix.
    case 'Literal':
      return literal(term.value, term.language || term.datatype);
    /*case 'Variable':
      return variable(term.value);*/ // Variables can not occur in JSON-LD bodies
    case 'DefaultGraph':
      return defaultGraph();
    }
  }
github beautifulinteractions / node-quadstore / test / rdfstore.prototype.match.js View on Github external
it('should match the default graph (explicit)',  async function () {
      const store = this.store;
      const rs = store;
      const quads = [
        factory.quad(
          factory.namedNode('http://ex.com/s0'),
          factory.namedNode('http://ex.com/p0'),
          factory.literal('o0', 'en-gb'),
          factory.defaultGraph()
        ),
        factory.quad(
          factory.namedNode('http://ex.com/s1'),
          factory.namedNode('http://ex.com/p1'),
          factory.literal('o1', 'en-gb'),
          factory.namedNode('http://ex.com/g1')
        )
      ];
      const source = utils.createArrayStream(quads);
      await utils.waitForEvent(store.import(source), 'end', true);
      const matchedQuads = await utils.streamToArray(rs.match(null, null, null, factory.defaultGraph()));
      stripTermSerializedValue(matchedQuads);
      should(matchedQuads).have.length(1);
      should(matchedQuads[0]).deepEqual(quads[0]);
    });
github beautifulinteractions / node-quadstore / test / rdfstore.prototype.match.js View on Github external
factory.quad(
          factory.namedNode('http://ex.com/s0'),
          factory.namedNode('http://ex.com/p0'),
          factory.literal('o0', 'en-gb'),
          factory.defaultGraph()
        ),
        factory.quad(
          factory.namedNode('http://ex.com/s1'),
          factory.namedNode('http://ex.com/p1'),
          factory.literal('o1', 'en-gb'),
          factory.namedNode('http://ex.com/g1')
        )
      ];
      const source = utils.createArrayStream(quads);
      await utils.waitForEvent(store.import(source), 'end', true);
      const matchedQuads = await utils.streamToArray(rs.match(null, null, null, factory.defaultGraph()));
      stripTermSerializedValue(matchedQuads);
      should(matchedQuads).have.length(1);
      should(matchedQuads[0]).deepEqual(quads[0]);
    });
github stephank / castling.club / src / shared / jsonld.js View on Github external
const fromPlainTerm = plainTerm => {
  switch (plainTerm.termType) {
    case "NamedNode":
      return rdf.namedNode(plainTerm.value);
    case "BlankNode":
      return rdf.blankNode(plainTerm.value.substr(2));
    case "Literal":
      return rdf.literal(
        plainTerm.value,
        plainTerm.language || rdf.namedNode(plainTerm.datatype.value)
      );
    case "DefaultGraph":
      return rdf.defaultGraph();
    default:
      throw Error("unknown termType: " + plainTerm.termType);
  }
};
github pietercolpaert / ldfetch / lib / JsonldToRDF.js View on Github external
term (plainTerm) {
    switch (plainTerm.termType) {
      case 'NamedNode':
        return DataFactory.namedNode(plainTerm.value)
      case 'BlankNode':
        return DataFactory.blankNode(plainTerm.value.substr(2))
      case 'Literal':
        return DataFactory.literal(plainTerm.value, plainTerm.language || DataFactory.namedNode(plainTerm.datatype.value))
      case 'DefaultGraph':
        return DataFactory.defaultGraph()
      default:
        throw Error('unknown termType: ' + plainTerm.termType)
    }
  }

@rdfjs/data-model

A basic implementation of the RDF/JS Data Model

MIT
Latest version published 9 months ago

Package Health Score

61 / 100
Full package analysis