New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

n3

Package Overview
Dependencies
Maintainers
1
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

n3 - npm Package Compare versions

Comparing version 0.6.1 to 0.7.0

20

lib/N3Store.js

@@ -5,2 +5,5 @@ // **N3Store** objects store N3 triples by graph in memory.

// IRI of the default graph
var DEFAULT_GRAPH = 'urn:n3:defaultGraph';
// ## Constructor

@@ -33,3 +36,2 @@ function N3Store(triples, options) {

this.addPrefixes(options.prefixes);
this.defaultGraph = options.defaultGraph || 'http://example.org/#defaultGraph';
if (triples)

@@ -58,2 +60,8 @@ this.addTriples(triples);

// ### `defaultGraph` returns the IRI of the default graph in the store.
// Use it to search in the default graph only with `find`.
get defaultGraph() {
return DEFAULT_GRAPH;
},
// ## Private methods

@@ -164,3 +172,3 @@

// Find the graph that will contain the triple.
graph = graph || this.defaultGraph;
graph = graph || DEFAULT_GRAPH;
var graphItem = this._graphs[graph];

@@ -216,3 +224,3 @@ // Create the graph if it doesn't exist yet.

predicate = subject.predicate, subject = subject.subject;
graph = graph || this.defaultGraph;
graph = graph || DEFAULT_GRAPH;

@@ -282,2 +290,6 @@ // Find internal identifiers for all components.

// Do not emit the default graph explicitly
if (graphId === DEFAULT_GRAPH)
graphId = '';
// Choose the optimal index, based on what fields are present

@@ -328,3 +340,3 @@ if (subjectId) {

countByIRI: function (subject, predicate, object, graph) {
graph = graph || this.defaultGraph;
graph = graph || DEFAULT_GRAPH;
var graphItem = this._graphs[graph], ids = this._ids;

@@ -331,0 +343,0 @@

2

package.json
{
"name": "n3",
"version": "0.6.1",
"version": "0.7.0",
"description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.",

@@ -5,0 +5,0 @@ "author": "Ruben Verborgh <ruben.verborgh@gmail.com>",

@@ -51,21 +51,8 @@ var N3Store = require('../N3').Store;

});
});
describe('An N3Store without a configured default graph', function () {
var store = new N3Store();
it('should have a dummy default graph', function () {
store.defaultGraph.should.eql('http://example.org/#defaultGraph');
it('should have a fixed default graph', function () {
store.defaultGraph.should.eql('urn:n3:defaultGraph');
});
});
describe('An N3Store with a configured default graph', function () {
var dg = 'http://example.org/#defaultGraph';
var store = new N3Store({ defaultGraph: dg });
it('should return that configured default graph', function () {
store.defaultGraph.should.eql(dg);
});
});
describe('An N3Store with initialized with 3 elements', function () {

@@ -124,3 +111,3 @@ var store = new N3Store([

describe('An N3Store with 5 elements', function () {
var store = new N3Store({ defaultGraph: 'http://example.org/#defaultGraph' });
var store = new N3Store();
store.addTriple('s1', 'p1', 'o1').should.be.true;

@@ -141,6 +128,6 @@ store.addTriple({ subject: 's1', predicate: 'p1', object: 'o2' }).should.be.true;

shouldIncludeAll(store.find(),
['s1', 'p1', 'o1', store.defaultGraph],
['s1', 'p1', 'o2', store.defaultGraph],
['s1', 'p2', 'o2', store.defaultGraph],
['s2', 'p1', 'o1', store.defaultGraph],
['s1', 'p1', 'o1'],
['s1', 'p1', 'o2'],
['s1', 'p2', 'o2'],
['s2', 'p1', 'o1'],
['s1', 'p2', 'o3', 'c4']));

@@ -152,5 +139,5 @@ });

shouldIncludeAll(store.find('s1', null, null),
['s1', 'p1', 'o1', store.defaultGraph],
['s1', 'p1', 'o2', store.defaultGraph],
['s1', 'p2', 'o2', store.defaultGraph],
['s1', 'p1', 'o1'],
['s1', 'p1', 'o2'],
['s1', 'p2', 'o2'],
['s1', 'p2', 'o3', 'c4']));

@@ -170,5 +157,5 @@ });

shouldIncludeAll(store.find(null, 'p1', null),
['s1', 'p1', 'o1', store.defaultGraph],
['s1', 'p1', 'o2', store.defaultGraph],
['s2', 'p1', 'o1', store.defaultGraph]));
['s1', 'p1', 'o1'],
['s1', 'p1', 'o2'],
['s2', 'p1', 'o1']));
});

@@ -183,4 +170,4 @@

shouldIncludeAll(store.find(null, null, 'o1'),
['s1', 'p1', 'o1', store.defaultGraph],
['s2', 'p1', 'o1', store.defaultGraph]));
['s1', 'p1', 'o1'],
['s2', 'p1', 'o1']));
});

@@ -195,4 +182,4 @@

shouldIncludeAll(store.find('s1', 'p1', null),
['s1', 'p1', 'o1', store.defaultGraph],
['s1', 'p1', 'o2', store.defaultGraph]));
['s1', 'p1', 'o1'],
['s1', 'p1', 'o2']));
});

@@ -207,4 +194,4 @@

shouldIncludeAll(store.find('s1', null, 'o2'),
['s1', 'p1', 'o2', store.defaultGraph],
['s1', 'p2', 'o2', store.defaultGraph]));
['s1', 'p1', 'o2'],
['s1', 'p2', 'o2']));
});

@@ -219,4 +206,4 @@

shouldIncludeAll(store.find(null, 'p1', 'o1'),
['s1', 'p1', 'o1', store.defaultGraph],
['s2', 'p1', 'o1', store.defaultGraph]));
['s1', 'p1', 'o1'],
['s2', 'p1', 'o1']));
});

@@ -230,3 +217,3 @@

it('should return all items with this subject, predicate, and object in the default graph',
shouldIncludeAll(store.find('s1', 'p1', 'o1'), ['s1', 'p1', 'o1', store.defaultGraph]));
shouldIncludeAll(store.find('s1', 'p1', 'o1'), ['s1', 'p1', 'o1']));
});

@@ -241,6 +228,6 @@

shouldIncludeAll(store.find(null, null, null, store.defaultGraph),
['s1', 'p1', 'o1', store.defaultGraph],
['s1', 'p1', 'o2', store.defaultGraph],
['s1', 'p2', 'o2', store.defaultGraph],
['s2', 'p1', 'o1', store.defaultGraph]));
['s1', 'p1', 'o1'],
['s1', 'p1', 'o2'],
['s1', 'p2', 'o2'],
['s2', 'p1', 'o1']));
});

@@ -423,6 +410,6 @@

shouldIncludeAll(function () { return store.find(); },
['s1', 'p1', 'o2', store.defaultGraph],
['s1', 'p2', 'o2', store.defaultGraph],
['s2', 'p1', 'o1', store.defaultGraph],
['s1', 'p2', 'o3', 'c4', store.defaultGraph]));
['s1', 'p1', 'o2'],
['s1', 'p2', 'o2'],
['s2', 'p1', 'o1'],
['s1', 'p2', 'o3', 'c4']));
});

@@ -450,3 +437,3 @@

shouldIncludeAll(function () { return store.find(); },
['s1', 'p1', 'o2', store.defaultGraph]));
['s1', 'p1', 'o2']));
});

@@ -477,4 +464,4 @@

shouldIncludeAll(store.find('a:s1', null, null),
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1'],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1'],
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', 'http://graphs.org/#g1']));

@@ -486,4 +473,4 @@ });

shouldIncludeAll(store.find('a:s1', null, null, store.defaultGraph),
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1', store.defaultGraph]));
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1'],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1']));
});

@@ -494,4 +481,4 @@

shouldIncludeAll(store.find(null, 'b:p1', null),
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s2', 'http://bar.org/p1', 'http://foo.org/#o2', store.defaultGraph],
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1'],
['http://foo.org/#s2', 'http://bar.org/p1', 'http://foo.org/#o2'],
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', 'http://graphs.org/#g1']));

@@ -503,4 +490,4 @@ });

shouldIncludeAll(store.find(null, null, 'a:o1'),
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1'],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1'],
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', 'http://graphs.org/#g1']));

@@ -512,3 +499,3 @@ });

shouldIncludeAll(store.find(null, null, null, 'http://graphs.org/#g1'),
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', 'http://graphs.org/#g1', store.defaultGraph]));
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', 'http://graphs.org/#g1']));
});

@@ -531,4 +518,4 @@ });

shouldIncludeAll(store.find('a:s1', null, null, store.defaultGraph),
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1', store.defaultGraph]));
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1'],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1']));
});

@@ -539,4 +526,4 @@

shouldIncludeAll(store.find('a:s1', null, null),
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1'],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1'],
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', 'http://graphs.org/#g1']));

@@ -548,4 +535,4 @@ });

shouldIncludeAll(store.find(null, 'b:p1', null, store.defaultGraph),
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s2', 'http://bar.org/p1', 'http://foo.org/#o2', store.defaultGraph]));
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1'],
['http://foo.org/#s2', 'http://bar.org/p1', 'http://foo.org/#o2']));
});

@@ -556,4 +543,4 @@

shouldIncludeAll(store.find(null, 'b:p1', null),
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s2', 'http://bar.org/p1', 'http://foo.org/#o2', store.defaultGraph],
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1'],
['http://foo.org/#s2', 'http://bar.org/p1', 'http://foo.org/#o2'],
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', 'http://graphs.org/#g1']));

@@ -565,4 +552,4 @@ });

shouldIncludeAll(store.find(null, null, 'a:o1', store.defaultGraph),
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1', store.defaultGraph]));
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1'],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1']));
});

@@ -573,4 +560,4 @@

shouldIncludeAll(store.find(null, null, 'a:o1'),
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1'],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1'],
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', 'http://graphs.org/#g1']));

@@ -597,4 +584,4 @@ });

shouldIncludeAll(store.find('http://foo.org/#s1', null, null),
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1', store.defaultGraph],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1', store.defaultGraph]));
['http://foo.org/#s1', 'http://bar.org/p1', 'http://foo.org/#o1'],
['http://foo.org/#s1', 'http://bar.org/p2', 'http://foo.org/#o1']));
});

@@ -610,3 +597,3 @@ });

shouldIncludeAll(store.find(null, 'http:b', null),
['a', 'http://www.w3.org/2006/http#b', 'c', store.defaultGraph]));
['a', 'http://www.w3.org/2006/http#b', 'c']));
});

@@ -616,3 +603,3 @@ });

describe('An N3Store containing a blank node', function () {
var store = new N3Store({ defaultGraph: 'http://example.org/#defaultGraph' });
var store = new N3Store();
var b1 = store.createBlankNode();

@@ -624,3 +611,3 @@ store.addTriple('s1', 'p1', b1).should.be.true;

shouldIncludeAll(store.find(),
['s1', 'p1', b1, store.defaultGraph]));
['s1', 'p1', b1]));
});

@@ -631,3 +618,3 @@

shouldIncludeAll(store.find('s1', 'p1'),
['s1', 'p1', b1, store.defaultGraph]));
['s1', 'p1', b1]));
});

@@ -634,0 +621,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc