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

rdf-canonize

Package Overview
Dependencies
Maintainers
4
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rdf-canonize - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

28

lib/NQuads.js

@@ -203,14 +203,12 @@ /*

/**
* Converts an RDF quad to an N-Quad string (a single quad).
* Converts RDF quad components to an N-Quad string (a single quad).
*
* @param quad the RDF quad convert.
* @param {Object} s - N-Quad subject component.
* @param {Object} p - N-Quad predicate component.
* @param {Object} o - N-Quad object component.
* @param {Object} g - N-Quad graph component.
*
* @return the N-Quad string.
* @return {string} the N-Quad.
*/
static serializeQuad(quad) {
const s = quad.subject;
const p = quad.predicate;
const o = quad.object;
const g = quad.graph;
static serializeQuadComponents(s, p, o, g) {
let nquad = '';

@@ -257,2 +255,14 @@

/**
* Converts an RDF quad to an N-Quad string (a single quad).
*
* @param quad the RDF quad convert.
*
* @return the N-Quad string.
*/
static serializeQuad(quad) {
return NQuads.serializeQuadComponents(
quad.subject, quad.predicate, quad.object, quad.graph);
}
/**
* Converts a legacy-formatted dataset to an array of quads dataset per

@@ -259,0 +269,0 @@ * http://rdf.js.org/.

@@ -151,9 +151,11 @@ /*

// previously issued by canonical issuer.
// Note: We optimize with shallow copies here.
const q = {...quad};
q.subject = this._useCanonicalId({component: q.subject});
q.object = this._useCanonicalId({component: q.object});
q.graph = this._useCanonicalId({component: q.graph});
// Note: We optimize away the copy here.
const nQuad = NQuads.serializeQuadComponents(
this._componentWithCanonicalId(quad.subject),
quad.predicate,
this._componentWithCanonicalId(quad.object),
this._componentWithCanonicalId(quad.graph)
);
// 7.2) Add quad copy to the normalized dataset.
normalized.push(NQuads.serializeQuad(q));
normalized.push(nQuad);
}

@@ -503,5 +505,7 @@

_useCanonicalId({component}) {
// canonical ids for 7.1
_componentWithCanonicalId(component) {
if(component.termType === 'BlankNode' &&
!component.value.startsWith(this.canonicalIssuer.prefix)) {
// create new BlankNode
return {

@@ -508,0 +512,0 @@ termType: 'BlankNode',

@@ -146,9 +146,11 @@ /*

// previously issued by canonical issuer.
// Note: We optimize with shallow copies here.
const q = {...quad};
q.subject = this._useCanonicalId({component: q.subject});
q.object = this._useCanonicalId({component: q.object});
q.graph = this._useCanonicalId({component: q.graph});
// Note: We optimize away the copy here.
const nQuad = NQuads.serializeQuadComponents(
this._componentWithCanonicalId({component: quad.subject}),
quad.predicate,
this._componentWithCanonicalId({component: quad.object}),
this._componentWithCanonicalId({component: quad.graph})
);
// 7.2) Add quad copy to the normalized dataset.
normalized.push(NQuads.serializeQuad(q));
normalized.push(nQuad);
}

@@ -485,5 +487,7 @@

_useCanonicalId({component}) {
// canonical ids for 7.1
_componentWithCanonicalId({component}) {
if(component.termType === 'BlankNode' &&
!component.value.startsWith(this.canonicalIssuer.prefix)) {
// create new BlankNode
return {

@@ -490,0 +494,0 @@ termType: 'BlankNode',

{
"name": "rdf-canonize",
"version": "3.1.0",
"version": "3.2.0",
"description": "An implementation of the RDF Dataset Normalization Algorithm in JavaScript",

@@ -54,3 +54,3 @@ "homepage": "https://github.com/digitalbazaar/rdf-canonize",

"scripts": {
"fetch-test-suite": "if [ ! -e test-suites/normalization ]; then git clone --depth 1 https://github.com/json-ld/normalization.git test-suites/normalization; fi",
"fetch-test-suite": "if [ ! -e test-suites/rdf-dataset-canonicalization ]; then git clone --depth 1 https://github.com/json-ld/rdf-dataset-canonicalization.git test-suites/rdf-dataset-canonicalization; fi",
"test": "npm run test-node",

@@ -57,0 +57,0 @@ "test-node": "NODE_ENV=test mocha -R spec --check-leaks",

@@ -7,3 +7,3 @@ # rdf-canonize

An implementation of the [RDF Dataset Normalization Algorithm][] in JavaScript.
An implementation of the [RDF Dataset Canonicalization Algorithm][] in JavaScript.

@@ -88,3 +88,3 @@ Introduction

https://github.com/json-ld/normalization
https://github.com/json-ld/rdf-dataset-canonicalization

@@ -133,4 +133,4 @@ This should be a sibling directory of the rdf-canonize directory or in a

[JSON-LD]: https://json-ld.org/
[RDF Dataset Normalization Algorithm]: https://json-ld.github.io/normalization/
[RDF Dataset Canonicalization Algorithm]: https://json-ld.github.io/rdf-dataset-canonicalization/
[jsonld.js]: https://github.com/digitalbazaar/jsonld.js
[rdf-canonize-native]: https://github.com/digitalbazaar/rdf-canonize-native
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