Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

n3

Package Overview
Dependencies
Maintainers
1
Versions
125
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.1.5 to 0.1.6

lib/N3Util.js

3

lib/N3Lexer.js

@@ -265,3 +265,4 @@ // **N3Lexer** tokenizes N3 documents.

// Read strings, not buffers.
input.setEncoding('utf8');
if (typeof input.setEncoding === 'function')
input.setEncoding('utf8');

@@ -268,0 +269,0 @@ // If new data arrives…

@@ -5,1 +5,2 @@ exports.Store = require('./lib/N3Store');

exports.Transform = require('./lib/N3Transform');
exports.Util = require('./lib/N3Util');
{
"name": "n3",
"version": "0.1.5",
"version": "0.1.6",
"description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.",

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

@@ -78,2 +78,46 @@ # Lightning fast, asynchronous, streaming Turtle / N3 / RDF

## Representing URIs and literals
_node-n3_ has a special syntax to represent URIs and literals,
making code efficient to write and execute.
<br>
As URIs are most common, they are represented as simple strings:
``` js
var N3Util = require('n3').Util;
N3Util.isUri('http://example.org/cartoons#Mickey'); // true
```
Literals are represented as double quoted strings:
``` js
N3Util.isLiteral('"Mickey Mouse"'); // true
N3Util.isLiteral('"Mickey Mouse"@en'); // true
N3Util.isLiteral('"3"^^<http://www.w3.org/2001/XMLSchema#integer>'); // true
N3Util.isLiteral('"http://example.org/"'); // true
```
Note the difference between `'http://example.org/'` (URI) and `'"http://example.org/"'` (literal).
<br>
Also note that the double quoted literals are _not_ raw Turtle syntax:
``` js
N3Util.isLiteral('"This word is "quoted"!"'); // true
```
The above string represents the string _This word is "quoted"!_,
even though the correct Turtle syntax for that is `"This word is \"quoted\"!"`
_node-n3_ thus always parses literals, but adds quotes to differentiate from URIs:
``` js
new n3.Parser().parse('<a> <b> "This word is \\"quoted\\"!".', console.log);
// { subject: 'a', predicate: 'b', object: '"This word is "quoted"!"' }
```
For convenience, `N3Util` can also be loaded globally:
``` js
require('n3').Util(global);
isUri('http://example.org/cartoons#Mickey'); // true
isLiteral('"Mickey Mouse"'); // true
```
If desired, the methods can even be added directly on all strings:
``` js
require('n3').Util(String, true);
'http://example.org/cartoons#Mickey'.isUri(); // true
'"Mickey Mouse"'.isLiteral(); // true
```
## Installation

@@ -80,0 +124,0 @@ You can install the _n3_ library as an [npm](http://npmjs.org/) package.

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