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 1.0.5 to 1.1.0

4

lib/N3Parser.js
// **N3Parser** parses N3 documents.
var N3Lexer = require('./N3Lexer'),
var Lexer = require('./N3Lexer'),
DataFactory = require('./N3DataFactory'),

@@ -35,3 +35,3 @@ namespaces = require('./IRIs');

options.blankNodePrefix.replace(/^(?!_:)/, '_:');
this._lexer = options.lexer || new N3Lexer({ lineMode: isLineMode, n3: isN3 });
this._lexer = options.lexer || new Lexer({ lineMode: isLineMode, n3: isN3 });
// Disable explicit quantifiers by default

@@ -38,0 +38,0 @@ this._explicitQuantifiers = !!options.explicitQuantifiers;

// **N3Store** objects store N3 quads by graph in memory.
var DataFactory = require('./N3DataFactory');
var DataFactory = require('./N3DataFactory'),
Readable = require('stream').Readable;
var toId = DataFactory.internal.toId,

@@ -316,2 +317,13 @@ fromId = DataFactory.internal.fromId;

// ### `removeMatches` removes all matching quads from the store
// Setting any field to `undefined` or `null` indicates a wildcard.
removeMatches(subject, predicate, object, graph) {
return this.remove(this.match(subject, predicate, object, graph));
}
// ### `deleteGraph` removes all triples with the given graph from the store
deleteGraph(graph) {
return this.removeMatches(null, null, null, graph);
}
// ### `getQuads` returns an array of quads matching a pattern.

@@ -366,2 +378,21 @@ // Setting any field to `undefined` or `null` indicates a wildcard.

// ### `match` returns a stream of quads matching a pattern.
// Setting any field to `undefined` or `null` indicates a wildcard.
match(subject, predicate, object, graph) {
var self = this;
var stream = new Readable({ objectMode: true });
// Initialize stream once it is being read
stream._read = function () {
stream._read = function () {};
var quads = self.getQuads(subject, predicate, object, graph);
for (var quad of quads) {
stream.push(quad);
}
stream.push(null);
};
return stream;
}
// ### `countQuads` returns the number of quads matching a pattern.

@@ -368,0 +399,0 @@ // Setting any field to `undefined` or `null` indicates a wildcard.

# License
The MIT License (MIT)
Copyright ©2012–2018 Ruben Verborgh
Copyright ©2012–present Ruben Verborgh

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

{
"name": "n3",
"version": "1.0.5",
"version": "1.1.0",
"description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.",

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

@@ -46,2 +46,3 @@ # Lightning fast, asynchronous, streaming RDF for JavaScript

[_Introduction to browserify_](https://writingjavascript.org/posts/introduction-to-browserify).
You will need to create a "UMD bundle" and supply a name (e.g. with the `-s N3` option in browserify).

@@ -104,4 +105,4 @@ ## Creating triples/quads

```JavaScript
const parser1 = N3.Parser({ format: 'N-Triples' });
const parser2 = N3.Parser({ format: 'application/trig' });
const parser1 = new N3.Parser({ format: 'N-Triples' });
const parser2 = new N3.Parser({ format: 'application/trig' });
```

@@ -112,5 +113,5 @@

```JavaScript
const parser3 = N3.Parser({ format: 'N3' });
const parser4 = N3.Parser({ format: 'Notation3' });
const parser5 = N3.Parser({ format: 'text/n3' });
const parser3 = new N3.Parser({ format: 'N3' });
const parser4 = new N3.Parser({ format: 'Notation3' });
const parser5 = new N3.Parser({ format: 'text/n3' });
```

@@ -122,3 +123,3 @@

const parser = new N3.Parser({ baseIRI: 'http://example.org/' });
```
```

@@ -131,3 +132,3 @@ ### From an RDF stream to quads

```JavaScript
const parser = N3.Parser(),
const parser = new N3.Parser(),
rdfStream = fs.createReadStream('cartoons.ttl');

@@ -142,3 +143,3 @@ parser.parse(rdfStream, console.log);

```JavaScript
const streamParser = N3.StreamParser(),
const streamParser = new N3.StreamParser(),
rdfStream = fs.createReadStream('cartoons.ttl');

@@ -168,3 +169,3 @@ rdfStream.pipe(streamParser);

```JavaScript
const writer = N3.Writer({ prefixes: { c: 'http://example.org/cartoons#' } });
const writer = new N3.Writer({ prefixes: { c: 'http://example.org/cartoons#' } });
writer.addQuad(

@@ -188,4 +189,4 @@ namedNode('http://example.org/cartoons#Tom'),

```JavaScript
const writer1 = N3.Writer({ format: 'N-Triples' });
const writer2 = N3.Writer({ format: 'application/trig' });
const writer1 = new N3.Writer({ format: 'N-Triples' });
const writer2 = new N3.Writer({ format: 'application/trig' });
```

@@ -198,3 +199,3 @@

```JavaScript
const writer = N3.Writer(process.stdout, { end: false, prefixes: { c: 'http://example.org/cartoons#' } });
const writer = new N3.Writer(process.stdout, { end: false, prefixes: { c: 'http://example.org/cartoons#' } });
writer.addQuad(

@@ -234,3 +235,3 @@ namedNode('http://example.org/cartoons#Tom'),

```JavaScript
const writer = N3.Writer({ prefixes: { c: 'http://example.org/cartoons#',
const writer = new N3.Writer({ prefixes: { c: 'http://example.org/cartoons#',
foaf: 'http://xmlns.com/foaf/0.1/' } });

@@ -275,5 +276,5 @@ writer.addQuad(

```JavaScript
const store = N3.Store();
const store = new N3.Store();
store.addQuad(
namedNode('http://ex.org/Pluto'),
namedNode('http://ex.org/Pluto'),
namedNode('http://ex.org/type'),

@@ -299,2 +300,5 @@ namedNode('http://ex.org/Dog')

- `removeQuads` to remove an array of quads
- `remove` to remove a stream of quads
- `removeMatches` to remove all quads matching the given pattern
- `deleteGraph` to remove all quads with the given graph
- `createBlankNode` returns an unused blank node identifier

@@ -306,2 +310,3 @@

- `getQuads` returns an array of quads matching the given pattern
- `match` returns a stream of quads matching the given pattern
- `countQuads` counts the number of quads matching the given pattern

@@ -341,24 +346,26 @@ - `forEach` executes a callback on all matching quads

- `N3.DataFactory` implements
[`DataFactory`](http://rdf.js.org/#datafactory-interface)
- the terms it creates implement [`Term`](http://rdf.js.org/#term-interface)
[`DataFactory`](http://rdf.js.org/data-model-spec/#datafactory-interface)
- the terms it creates implement [`Term`](http://rdf.js.org/data-model-spec/#term-interface)
and one of
[`NamedNode`](http://rdf.js.org/#namednode-interface),
[`BlankNode`](http://rdf.js.org/#blanknode-interface),
[`Literal`](http://rdf.js.org/#litereal-interface),
[`Variable`](http://rdf.js.org/#variable-interface),
[`DefaultGraph`](http://rdf.js.org/#defaultgraph-interface)
[`NamedNode`](http://rdf.js.org/data-model-spec/#namednode-interface),
[`BlankNode`](http://rdf.js.org/data-model-spec/#blanknode-interface),
[`Literal`](http://rdf.js.org/data-model-spec/#litereal-interface),
[`Variable`](http://rdf.js.org/data-model-spec/#variable-interface),
[`DefaultGraph`](http://rdf.js.org/data-model-spec/#defaultgraph-interface)
- the triples/quads it creates implement
[`Triple`](http://rdf.js.org/#triple-interface)
[`Triple`](http://rdf.js.org/data-model-spec/#triple-interface)
and
[`Quad`](http://rdf.js.org/#quad-interface)
[`Quad`](http://rdf.js.org/data-model-spec/#quad-interface)
- `N3.StreamParser` implements
[`Stream`](http://rdf.js.org/#stream-interface)
[`Stream`](http://rdf.js.org/stream-spec/#stream-interface)
and
[`Sink`](http://rdf.js.org/#sink-interface)
[`Sink`](http://rdf.js.org/stream-spec/#sink-interface)
- `N3.StreamWriter` implements
[`Stream`](http://rdf.js.org/#stream-interface)
[`Stream`](http://rdf.js.org/stream-spec/#stream-interface)
and
[`Sink`](http://rdf.js.org/#sink-interface)
[`Sink`](http://rdf.js.org/stream-spec/#sink-interface)
- `N3.Store` implements
[`Sink`](http://rdf.js.org/#sink-interface)
[`Store`](http://rdf.js.org/stream-spec/#store-interface)
[`Source`](http://rdf.js.org/stream-spec/#source-interface)
[`Sink`](http://rdf.js.org/stream-spec/#sink-interface)

@@ -365,0 +372,0 @@ ## License and contributions

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