Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should match quads by object', 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/g2')
),
factory.quad(
factory.namedNode('http://ex.com/s'),
factory.namedNode('http://ex.com/p'),
factory.literal('o2', 'en-gb'),
factory.namedNode('http://ex.com/g2')
)
];
const source = utils.createArrayStream(quads);
await utils.waitForEvent(store.import(source), 'end', true);
const object = factory.literal('o2', 'en-gb');
const matchedQuads = await utils.streamToArray(rs.match(null, null, object));
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);
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);
const fromPlainQuad = plainQuad =>
rdf.quad(
fromPlainTerm(plainQuad.subject),
fromPlainTerm(plainQuad.predicate),
fromPlainTerm(plainQuad.object),
fromPlainTerm(plainQuad.graph)
);