Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
skipExpansion: false,
contextResolver: new ContextResolver(
{sharedCache: _resolvedContextCache})
});
if('inputFormat' in options) {
if(options.inputFormat !== 'application/n-quads' &&
options.inputFormat !== 'application/nquads') {
throw new JsonLdError(
'Unknown canonicalization input format.',
'jsonld.CanonizeError');
}
// TODO: `await` for async parsers
const parsedInput = NQuads.parse(input);
// do canonicalization
return canonize.canonize(parsedInput, options);
}
// convert to RDF dataset then do normalization
const opts = {...options};
delete opts.format;
opts.produceGeneralizedRdf = false;
const dataset = await jsonld.toRDF(input, opts);
// do canonicalization
return canonize.canonize(dataset, options);
};
}
// TODO: `await` for async parsers
const parsedInput = NQuads.parse(input);
// do canonicalization
return canonize.canonize(parsedInput, options);
}
// convert to RDF dataset then do normalization
const opts = {...options};
delete opts.format;
opts.produceGeneralizedRdf = false;
const dataset = await jsonld.toRDF(input, opts);
// do canonicalization
return canonize.canonize(dataset, options);
};
async function compareCanonizedExpectedNQuads(test, result) {
let expect;
try {
expect = await readTestNQuads(_getExpectProperty(test))(test);
const opts = {algorithm: 'URDNA2015'};
const expectDataset = rdfCanonize.NQuads.parse(expect);
const expectCmp = await rdfCanonize.canonize(expectDataset, opts);
const resultDataset = rdfCanonize.NQuads.parse(result);
const resultCmp = await rdfCanonize.canonize(resultDataset, opts);
assert.strictEqual(resultCmp, expectCmp);
} catch(err) {
if(options.bailOnError) {
console.log('\nTEST FAILED\n');
console.log('EXPECTED:\n' + expect);
console.log('ACTUAL:\n' + result);
}
throw err;
}
}
async function compareCanonizedExpectedNQuads(test, result) {
let expect;
try {
expect = await readTestNQuads(_getExpectProperty(test))(test);
const opts = {algorithm: 'URDNA2015'};
const expectDataset = rdfCanonize.NQuads.parse(expect);
const expectCmp = await rdfCanonize.canonize(expectDataset, opts);
const resultDataset = rdfCanonize.NQuads.parse(result);
const resultCmp = await rdfCanonize.canonize(resultDataset, opts);
assert.strictEqual(resultCmp, expectCmp);
} catch(err) {
if(options.bailOnError) {
console.log('\nTEST FAILED\n');
console.log('EXPECTED:\n' + expect);
console.log('ACTUAL:\n' + result);
}
throw err;
}
}