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
126
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.4.2 to 0.4.3

.eslintrc

4

lib/N3Parser.js

@@ -53,2 +53,4 @@ // **N3Parser** parses N3 documents.

}
this._blankNodePrefix = typeof options.blankNodePrefix !== 'string' ? '' :
'_:' + options.blankNodePrefix.replace(/^_:/, '');
this._lexer = options.lexer || new N3Lexer({ lineMode: isLineMode });

@@ -602,3 +604,3 @@ }

this._prefixes = Object.create(null);
this._prefixes._ = '_:b' + blankNodePrefix++ + '_';
this._prefixes._ = this._blankNodePrefix || '_:b' + blankNodePrefix++ + '_';

@@ -605,0 +607,0 @@ // If the input argument is not given, shift parameters

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

if (index1 = index0[value0]) {
// If a key is specified, count only that part of index 1.

@@ -194,3 +193,3 @@ if (key1) (tmp = index1, index1 = {})[key1] = tmp[key1];

// ### `addPrefixex` adds support for querying with the given prefixes
// ### `addPrefixes` adds support for querying with the given prefixes
addPrefixes: function (prefixes) {

@@ -214,3 +213,3 @@ for (var prefix in prefixes)

if (!(object = entities[object])) return;
if (!(graphItem = graphs[graph])) return;
if (!(graphItem = graphs[graph])) return;

@@ -217,0 +216,0 @@ // Verify that the triple exists.

@@ -24,17 +24,20 @@ // **N3Writer** writes N3 documents.

options = outputStream, outputStream = null;
options = options || {};
// If no output stream given, send the output as string through the end callback
if (!outputStream) {
outputStream = this;
this._output = '';
this.write = function (chunk, encoding, callback) {
this._output += chunk;
callback && callback();
var output = '';
this._outputStream = {
write: function (chunk, encoding, done) { output += chunk; done && done(); },
end: function (done) { done && done(null, output); },
};
this._endStream = true;
}
this._outputStream = outputStream;
else {
this._outputStream = outputStream;
this._endStream = options.end === undefined ? true : !!options.end;
}
// Initialize writer, depending on the format
this._subject = null;
options = options || {};
if (!(/triple|quad/i).test(options.format)) {

@@ -234,12 +237,9 @@ this._graph = '';

// If writing to a string instead of an actual stream, send the string
if (this === this._outputStream)
return done && done(null, this._output);
// Try to end the underlying stream, ensuring done is called exactly one time
var singleDone = done && function () { singleDone = null, done(); };
// Ending a stream can error
try { this._outputStream.end(singleDone); }
// Execute the callback if it hasn't been executed
catch (error) { singleDone && singleDone(); }
var singleDone = done && function (error, result) { singleDone = null, done(error, result); };
if (this._endStream) {
try { return this._outputStream.end(singleDone); }
catch (error) { /* error closing stream */ }
}
singleDone && singleDone();
},

@@ -246,0 +246,0 @@ };

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

@@ -20,2 +20,3 @@ "author": "Ruben Verborgh <ruben.verborgh@gmail.com>",

"async": "~0.9.0",
"browserify": "~3.x",
"chai": "~1.4.2",

@@ -25,13 +26,12 @@ "chai-things": "~0.1.1",

"docco": "~0.6.2",
"jshint": "~2.1.10",
"eslint": "~0.19.0",
"istanbul": "~0.3.0",
"mocha": "~1.15.0",
"pre-commit": "~0.0.9",
"request": "~2.22.0",
"mocha": "~1.15.0",
"istanbul": "~0.3.0",
"uglify-js": "~2.4.3",
"browserify": "~3.x",
"pre-commit": "~0.0.9"
"uglify-js": "~2.4.3"
},
"scripts": {
"test": "mocha",
"hint": "jshint lib perf test spec",
"lint": "eslint lib perf test spec",
"browser": "node browser/build-browser-versions",

@@ -63,5 +63,5 @@ "coverage": "istanbul cover node_modules/.bin/_mocha -- -R spec --timeout 100",

"pre-commit": [
"hint",
"lint",
"test"
]
}

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

inputStream = fs.createReadStream('cartoons.ttl'),
streamWriter = new N3.StreamWriter({ 'c': 'http://example.org/cartoons#' });
streamWriter = new N3.StreamWriter({ prefixes: { 'c': 'http://example.org/cartoons#' } });
inputStream.pipe(streamParser);

@@ -250,0 +250,0 @@ streamParser.pipe(streamWriter);

@@ -69,3 +69,4 @@ #!/usr/bin/env node

resultStream: self._fetch.bind(self, test.result), },
function (err, results) {
function (error, results) {
if (error) return callback(error);
self._performTest(test, results.actionStream, callback);

@@ -77,3 +78,3 @@ });

var score = tests.reduce(function (sum, test) { return sum + test.success; }, 0);
manifest.skipped.forEach(function (test) { self._verifyResult(test); });
manifest.skipped.forEach(function (test) { self._verifyResult(test); });
console.log(('* passed ' + score +

@@ -182,10 +183,8 @@ ' out of ' + manifest.tests.length + ' tests' +

// or if the correct solution is not given but no error occurred
else {
if (!correctFile)
displayResult(null, !test.error);
else if (!resultFile)
displayResult(null, false);
else
this._compareResultFiles(resultFile, correctFile, displayResult);
}
else if (!correctFile)
displayResult(null, !test.error);
else if (!resultFile)
displayResult(null, false);
else
this._compareResultFiles(resultFile, correctFile, displayResult);

@@ -245,3 +244,3 @@ // Display the test result

var reportFile = path.join(this._reportFolder, 'n3js-earl-report-' + this._name + '.ttl'),
report = new N3.Writer(fs.createWriteStream(reportFile), { prefixes: prefixes }),
report = new N3.Writer(fs.createWriteStream(reportFile), { prefixes: prefixes }),
date = '"' + new Date().toISOString() + '"^^' + prefixes.xsd + 'dateTime',

@@ -248,0 +247,0 @@ homepage = 'https://github.com/RubenVerborgh/N3.js', app = homepage + '#n3js',

@@ -758,6 +758,24 @@ var N3Parser = require('../N3').Parser;

describe('An N3Parser instance with a blank node prefix', function () {
var parser = new N3Parser({ blankNodePrefix: '_:blank' });
it('should use the given prefix for blank nodes',
shouldParse(parser,
'_:a <b> _:c.\n',
['_:blanka', 'b', '_:blankc']));
});
describe('An N3Parser instance with an empty blank node prefix', function () {
var parser = new N3Parser({ blankNodePrefix: '' });
it('should not use a prefix for blank nodes',
shouldParse(parser,
'_:a <b> _:c.\n',
['_:a', 'b', '_:c']));
});
describe('An N3Parser instance with an invalid document IRI', function () {
it('cannot be created', function (done) {
try {
new N3Parser({ documentIRI: 'http://ex.org/doc/f#' });
var parser = new N3Parser({ documentIRI: 'http://ex.org/doc/f#' });
}

@@ -764,0 +782,0 @@ catch (error) {

@@ -90,3 +90,3 @@ var N3StreamParser = require('../N3').StreamParser;

var reader = new Readable();
reader._read = function () { this.push(items.shift()); };
reader._read = function () { this.push(items.shift() || null); };
return reader;

@@ -93,0 +93,0 @@ }

@@ -102,3 +102,3 @@ var N3StreamWriter = require('../N3').StreamWriter;

items = items.map(function (i) { return { subject: i[0], predicate: i[1], object: i[2] }; });
reader._read = function () { this.push(items.shift()); };
reader._read = function () { this.push(items.shift() || null); };
return reader;

@@ -105,0 +105,0 @@ }

@@ -200,3 +200,3 @@ var N3Writer = require('../N3').Writer;

write: function () {},
end: function () { throw 'error'; },
end: function () { throw new Error('error'); },
});

@@ -331,2 +331,29 @@ writer.end(done);

});
it('should end when the end option is not set', function (done) {
var outputStream = new QuickStream(), writer = N3Writer(outputStream, {});
outputStream.should.have.property('ended', false);
writer.end(function () {
outputStream.should.have.property('ended', true);
done();
});
});
it('should end when the end option is set to true', function (done) {
var outputStream = new QuickStream(), writer = N3Writer(outputStream, { end: true });
outputStream.should.have.property('ended', false);
writer.end(function () {
outputStream.should.have.property('ended', true);
done();
});
});
it('should not end when the end option is set to false', function (done) {
var outputStream = new QuickStream(), writer = N3Writer(outputStream, { end: false });
outputStream.should.have.property('ended', false);
writer.end(function () {
outputStream.should.have.property('ended', false);
done();
});
});
});

@@ -349,2 +376,3 @@ });

outputStream.result.should.equal(expectedResult);
outputStream.should.have.property('ended', true);
done(error);

@@ -376,6 +404,14 @@ }

function QuickStream() {
var stream = {}, buffer = '';
stream.write = function (chunk, encoding, callback) { buffer += chunk; callback && callback(); };
stream.end = function (callback) { stream.result = buffer; buffer = null; callback(); };
var stream = { ended: false }, buffer = '';
stream.write = function (chunk, encoding, callback) {
buffer += chunk;
callback && callback();
};
stream.end = function (callback) {
stream.ended = true;
stream.result = buffer;
buffer = null;
callback();
};
return stream;
}
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