How to use the @rdfjs/data-model.namedNode 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 solid / query-ldflex / src / ActivityHandler.js View on Github external
user = await root.user;
      }
      catch (error) {
        if (self.requireUser)
          throw error;
        return;
      }

      // Determine the storage location
      const storage = await root.user.pim$storage;
      const document = new URL(self.activitiesPath, storage || user).href;

      // Obtain results for every activity on the path
      const results = [];
      const actor = namedNode(user);
      type = namedNode(type);
      for await (const object of path) {
        if (object.termType === 'NamedNode') {
          const activity = { actor, type, object };
          for await (const result of self.createResults(activity, document, queryEngine))
            results.push(result);
        }
      }

      // Process all results and return paths starting from the returned terms
      for (const term of await self.processResults(results, document, queryEngine))
        yield root[term.value];
    });
  }
github beautifulinteractions / node-quadstore / test / rdfstore.prototype.match.js View on Github external
factory.quad(
          factory.namedNode('http://ex.com/s'),
          factory.namedNode('http://ex.com/p'),
          factory.literal('o', 'en-gb'),
          factory.namedNode('http://ex.com/g')
        ),
        factory.quad(
          factory.namedNode('http://ex.com/s'),
          factory.namedNode('http://ex.com/p2'),
          factory.literal('o', 'en-gb'),
          factory.namedNode('http://ex.com/g')
        )
      ];
      const source = utils.createArrayStream(quads);
      await utils.waitForEvent(store.import(source), 'end', true);
      const predicate = factory.namedNode('http://ex.com/p2');
      const matchedQuads = await utils.streamToArray(rs.match(null, predicate));
      stripTermSerializedValue(matchedQuads);
      should(matchedQuads).have.length(1);
      should(matchedQuads[0]).deepEqual(quads[1]);
    });
github beautifulinteractions / node-quadstore / test / rdfstore.prototype.match.js View on Github external
it('should match quads by the default graph (implicit)',  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.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 readStream = rs.match(null, null, null, factory.defaultGraph());
      const matchedQuads = await utils.streamToArray(readStream);
      stripTermSerializedValue(matchedQuads);
      should(matchedQuads).have.length(1);
      should(matchedQuads[0].graph).deepEqual(quads[0].graph);
    });
github beautifulinteractions / node-quadstore / test / rdfstore.prototype.match.js View on Github external
factory.quad(
          factory.namedNode('http://ex.com/s'),
          factory.namedNode('http://ex.com/p'),
          factory.literal('o', 'en-gb'),
          factory.namedNode('http://ex.com/g')
        ),
        factory.quad(
          factory.namedNode('http://ex.com/s2'),
          factory.namedNode('http://ex.com/p'),
          factory.literal('o', 'en-gb'),
          factory.namedNode('http://ex.com/g')
        )
      ];
      const source = utils.createArrayStream(quads);
      await utils.waitForEvent(store.import(source), 'end', true);
      const subject = factory.namedNode('http://ex.com/s2');
      const matchedQuads = await utils.streamToArray(rs.match(subject));
      stripTermSerializedValue(matchedQuads);
      should(matchedQuads).have.length(1);
      should(matchedQuads[0]).deepEqual(quads[1]);
    });
github beautifulinteractions / node-quadstore / test / rdfstore.prototype.match.js View on Github external
it('should match quads by predicate',  async function () {
      const store = this.store;
      const rs = store;
      const quads = [
        factory.quad(
          factory.namedNode('http://ex.com/s'),
          factory.namedNode('http://ex.com/p'),
          factory.literal('o', 'en-gb'),
          factory.namedNode('http://ex.com/g')
        ),
        factory.quad(
          factory.namedNode('http://ex.com/s'),
          factory.namedNode('http://ex.com/p2'),
          factory.literal('o', 'en-gb'),
          factory.namedNode('http://ex.com/g')
        )
      ];
      const source = utils.createArrayStream(quads);
      await utils.waitForEvent(store.import(source), 'end', true);
      const predicate = factory.namedNode('http://ex.com/p2');
      const matchedQuads = await utils.streamToArray(rs.match(null, predicate));
      stripTermSerializedValue(matchedQuads);
      should(matchedQuads).have.length(1);
      should(matchedQuads[0]).deepEqual(quads[1]);
    });
github beautifulinteractions / node-quadstore / test / rdfstore.prototype.match.js View on Github external
it('should match quads by subject', async function () {
      const store = this.store;
      const rs = store;
      const quads = [
        factory.quad(
          factory.namedNode('http://ex.com/s'),
          factory.namedNode('http://ex.com/p'),
          factory.literal('o', 'en-gb'),
          factory.namedNode('http://ex.com/g')
        ),
        factory.quad(
          factory.namedNode('http://ex.com/s2'),
          factory.namedNode('http://ex.com/p'),
          factory.literal('o', 'en-gb'),
          factory.namedNode('http://ex.com/g')
        )
      ];
      const source = utils.createArrayStream(quads);
      await utils.waitForEvent(store.import(source), 'end', true);
      const subject = factory.namedNode('http://ex.com/s2');
      const matchedQuads = await utils.streamToArray(rs.match(subject));
      stripTermSerializedValue(matchedQuads);
      should(matchedQuads).have.length(1);
      should(matchedQuads[0]).deepEqual(quads[1]);
    });
github beautifulinteractions / node-quadstore / test / rdfstore.prototype.match.js View on Github external
it('should match quads by predicate',  async function () {
      const store = this.store;
      const rs = store;
      const quads = [
        factory.quad(
          factory.namedNode('http://ex.com/s'),
          factory.namedNode('http://ex.com/p'),
          factory.literal('o', 'en-gb'),
          factory.namedNode('http://ex.com/g')
        ),
        factory.quad(
          factory.namedNode('http://ex.com/s'),
          factory.namedNode('http://ex.com/p2'),
          factory.literal('o', 'en-gb'),
          factory.namedNode('http://ex.com/g')
        )
      ];
      const source = utils.createArrayStream(quads);
      await utils.waitForEvent(store.import(source), 'end', true);
      const predicate = factory.namedNode('http://ex.com/p2');
      const matchedQuads = await utils.streamToArray(rs.match(null, predicate));
      stripTermSerializedValue(matchedQuads);
      should(matchedQuads).have.length(1);
      should(matchedQuads[0]).deepEqual(quads[1]);
    });
github solid / query-ldflex / src / CreateActivityHandler.js View on Github external
async* createResults(activity, document) {
    const id = namedNode(new URL(`#${uuid()}`, document).href);
    const published = literal(new Date().toISOString(), `${xsd}dateTime`);
    activity = { id, published, ...activity };

    const insert = replaceVariables(activityTemplate, activity);
    yield { id, insert };
  }
github solid / query-ldflex / src / SubjectPathResolver.js View on Github external
resolve(property) {
    return this._createSubjectPath(namedNode(property));
  }
github comunica / comunica / packages / actor-rdf-resolve-quad-pattern-sparql-json / lib / ActorRdfResolveQuadPatternSparqlJson.ts View on Github external
public static patternToCountQuery(pattern: RDF.Quad): string {
    return toSparql(ActorRdfResolveQuadPatternSparqlJson.FACTORY.createProject(
      ActorRdfResolveQuadPatternSparqlJson.FACTORY.createExtend(
        ActorRdfResolveQuadPatternSparqlJson.FACTORY.createGroup(
          ActorRdfResolveQuadPatternSparqlJson.patternToBgp(pattern),
          [],
          [ActorRdfResolveQuadPatternSparqlJson.FACTORY.createBoundAggregate(
            variable('var0'),
            'count',
            ActorRdfResolveQuadPatternSparqlJson.FACTORY.createTermExpression(namedNode('*')),
            false,
          )],
        ),
        variable('count'),
        ActorRdfResolveQuadPatternSparqlJson.FACTORY.createTermExpression(variable('var0')),
      ),
      [ variable('count') ],
    ));
  }

@rdfjs/data-model

A basic implementation of the RDF/JS Data Model

MIT
Latest version published 11 months ago

Package Health Score

65 / 100
Full package analysis