Skip to content

Commit 9f05093

Browse files
Merge pull request #30 from OriginTrail/version-bump/806
version bump
2 parents 771e59a + b07f60a commit 9f05093

File tree

3 files changed

+13
-25
lines changed

3 files changed

+13
-25
lines changed

index.cjs

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -366,16 +366,16 @@ function groupNquadsBySubject(nquadsArray, sort = false) {
366366
const grouped = {};
367367

368368
parser.parse(nquadsArray.join("")).forEach((quad) => {
369-
const { subject, predicate, object } = quad;
369+
const { subject } = quad;
370370

371371
let subjectKey;
372372
if (subject.termType === "Quad") {
373373
const nestedSubject = subject.subject.value;
374374
const nestedPredicate = subject.predicate.value;
375375
const nestedObject =
376376
subject.object.termType === "Literal"
377-
? `"${escapeLiteral(subject.object.value)}"`
378-
: `<${escapeLiteral(subject.object.value)}>`;
377+
? `"${subject.object.value}"`
378+
: `<${subject.object.value}>`;
379379
subjectKey = `<<<${nestedSubject}> <${nestedPredicate}> ${nestedObject}>>`;
380380
} else {
381381
subjectKey = `<${subject.value}>`;
@@ -385,12 +385,14 @@ function groupNquadsBySubject(nquadsArray, sort = false) {
385385
grouped[subjectKey] = [];
386386
}
387387

388-
const objectValue =
389-
object.termType === "Literal"
390-
? `"${escapeLiteral(object.value)}"`
391-
: `<${escapeLiteral(object.value)}>`;
388+
const writer = new N3.Writer({ format: "N-Quads" });
389+
let quadString = "";
390+
writer.addQuad(quad);
391+
writer.end((error, result) => {
392+
if (error) throw error;
393+
quadString = result.trim();
394+
});
392395

393-
const quadString = `${subjectKey} <${predicate.value}> ${objectValue} .`;
394396
grouped[subjectKey].push(quadString);
395397
});
396398

@@ -534,20 +536,6 @@ function isEmptyObject(obj) {
534536
return Object.keys(obj).length === 0 && obj.constructor === Object;
535537
}
536538

537-
function escapeLiteral(value) {
538-
const ESCAPE_MAP = {
539-
'"': '\\"',
540-
"\\": "\\\\",
541-
"\b": "\\b",
542-
"\f": "\\f",
543-
"\n": "\\n",
544-
"\r": "\\r",
545-
"\t": "\\t",
546-
};
547-
548-
return value.replace(/["\\\b\f\n\r\t]/g, (char) => ESCAPE_MAP[char]);
549-
}
550-
551539
var knowledgeCollectionTools = /*#__PURE__*/Object.freeze({
552540
__proto__: null,
553541
calculateByteSize: calculateByteSize,

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "assertion-tools",
3-
"version": "8.0.5",
3+
"version": "8.0.6",
44
"description": "Common assertion tools used in ot-node and dkg.js",
55
"main": "index.js",
66
"type": "module",

0 commit comments

Comments
 (0)