rdf-canonize
Advanced tools
Comparing version 3.3.0 to 3.4.0
@@ -6,3 +6,3 @@ /** | ||
* BSD 3-Clause License | ||
* Copyright (c) 2016-2022 Digital Bazaar, Inc. | ||
* Copyright (c) 2016-2023 Digital Bazaar, Inc. | ||
* All rights reserved. | ||
@@ -49,2 +49,11 @@ * | ||
// return a dataset from input dataset or legacy dataset | ||
function _inputToDataset(input/*, options*/) { | ||
// back-compat with legacy dataset | ||
if(!Array.isArray(input)) { | ||
return exports.NQuads.legacyDatasetToQuads(input); | ||
} | ||
return input; | ||
} | ||
// expose helpers | ||
@@ -71,3 +80,4 @@ exports.NQuads = require('./NQuads'); | ||
* | ||
* @param {Array} dataset - The dataset to canonize. | ||
* @param {Array|object|string} input - The input to canonize given as a | ||
* dataset or legacy dataset. | ||
* @param {object} options - The options to use: | ||
@@ -81,2 +91,5 @@ * {string} algorithm - The canonicalization algorithm to use, `URDNA2015` or | ||
* the canonize algorithm will result in different output. | ||
* {Map} [canonicalIdMap] - An optional Map to be populated by the canonical | ||
* identifier issuer with the bnode identifier mapping generated by the | ||
* canonicalization algorithm. | ||
* {boolean} [useNative=false] - Use native implementation. | ||
@@ -92,7 +105,4 @@ * {number} [maxDeepIterations=Infinity] - The maximum number of times to run | ||
*/ | ||
exports.canonize = async function(dataset, options) { | ||
// back-compat with legacy dataset | ||
if(!Array.isArray(dataset)) { | ||
dataset = exports.NQuads.legacyDatasetToQuads(dataset); | ||
} | ||
exports.canonize = async function(input, options) { | ||
const dataset = _inputToDataset(input, options); | ||
@@ -134,3 +144,4 @@ if(options.useNative) { | ||
* | ||
* @param {Array} dataset - The dataset to canonize. | ||
* @param {Array|object|string} input - The input to canonize given as a | ||
* dataset or legacy dataset. | ||
* @param {object} options - The options to use: | ||
@@ -154,7 +165,4 @@ * {string} algorithm - The canonicalization algorithm to use, `URDNA2015` or | ||
*/ | ||
exports._canonizeSync = function(dataset, options) { | ||
// back-compat with legacy dataset | ||
if(!Array.isArray(dataset)) { | ||
dataset = exports.NQuads.legacyDatasetToQuads(dataset); | ||
} | ||
exports._canonizeSync = function(input, options) { | ||
const dataset = _inputToDataset(input, options); | ||
@@ -161,0 +169,0 @@ if(options.useNative) { |
@@ -14,2 +14,3 @@ /*! | ||
createMessageDigest = () => new MessageDigest('sha256'), | ||
canonicalIdMap = new Map(), | ||
maxDeepIterations = Infinity | ||
@@ -19,3 +20,3 @@ } = {}) { | ||
this.blankNodeInfo = new Map(); | ||
this.canonicalIssuer = new IdentifierIssuer('_:c14n'); | ||
this.canonicalIssuer = new IdentifierIssuer('_:c14n', canonicalIdMap); | ||
this.createMessageDigest = createMessageDigest; | ||
@@ -22,0 +23,0 @@ this.maxDeepIterations = maxDeepIterations; |
@@ -16,2 +16,3 @@ /*! | ||
createMessageDigest = () => new MessageDigest('sha256'), | ||
canonicalIdMap = new Map(), | ||
maxDeepIterations = Infinity | ||
@@ -21,3 +22,3 @@ } = {}) { | ||
this.blankNodeInfo = new Map(); | ||
this.canonicalIssuer = new IdentifierIssuer('_:c14n'); | ||
this.canonicalIssuer = new IdentifierIssuer('_:c14n', canonicalIdMap); | ||
this.createMessageDigest = createMessageDigest; | ||
@@ -24,0 +25,0 @@ this.maxDeepIterations = maxDeepIterations; |
{ | ||
"name": "rdf-canonize", | ||
"version": "3.3.0", | ||
"version": "3.4.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/rdf-dataset-canonicalization ]; then git clone --depth 1 https://github.com/w3c-ccg/rdf-dataset-canonicalization.git test-suites/rdf-dataset-canonicalization; fi", | ||
"fetch-test-suite": "if [ ! -e test-suites/rdf-canon ]; then git clone --depth 1 https://github.com/w3c/rdf-canon.git test-suites/rdf-canon; fi", | ||
"test": "npm run test-node", | ||
@@ -57,0 +57,0 @@ "test-node": "NODE_ENV=test mocha -R spec --check-leaks", |
@@ -87,3 +87,3 @@ # rdf-canonize | ||
https://github.com/json-ld/rdf-dataset-canonicalization | ||
https://github.com/w3c/rdf-canon | ||
@@ -132,4 +132,4 @@ This should be a sibling directory of the rdf-canonize directory or in a | ||
[JSON-LD]: https://json-ld.org/ | ||
[RDF Dataset Canonicalization Algorithm]: https://json-ld.github.io/rdf-dataset-canonicalization/ | ||
[RDF Dataset Canonicalization Algorithm]: https://w3c.github.io/rdf-canon/spec/ | ||
[jsonld.js]: https://github.com/digitalbazaar/jsonld.js | ||
[rdf-canonize-native]: https://github.com/digitalbazaar/rdf-canonize-native |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
75367
1826