From 99accaa30ff0fd224add7b77e4d737c032d0618b Mon Sep 17 00:00:00 2001 From: Jesse Wright <63333554+jeswr@users.noreply.github.com> Date: Sat, 13 Apr 2024 16:50:10 +0100 Subject: [PATCH] feat: isImpliedBy --- lib/ttlwriter.ts | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ttlwriter.ts b/lib/ttlwriter.ts index f1a4035..c4330da 100644 --- a/lib/ttlwriter.ts +++ b/lib/ttlwriter.ts @@ -16,6 +16,7 @@ export interface Options { prefixes?: Record; format?: string; compact?: boolean; + isImpliedBy?: boolean; } function getNamespace(str: string) { @@ -25,6 +26,8 @@ function getNamespace(str: string) { export class TTLWriter { private isN3 = false; + private isImpliedBy = false; + private prefixes: { [prefix: string]: string } = {}; private prefixRev: { [namespace: string]: string } = {}; @@ -54,6 +57,8 @@ export class TTLWriter { throw new Error(`Unsupported format: ${options?.format}`); } + this.isImpliedBy = options?.isImpliedBy || false; + if (!this.isN3) { const graphs = store.getGraphs(null, null, null); @@ -219,6 +224,9 @@ export class TTLWriter { if (this.isN3 && term.value === 'http://www.w3.org/2000/10/swap/log#implies') { return '=>'; } + if (this.isN3 && this.isImpliedBy && term.value === 'http://www.w3.org/2000/10/swap/log#isImpliedBy') { + return '<='; + } const namespace = getNamespace(term.value); if (namespace && namespace in this.prefixRev) { if (namespace in this.prefixRev) { diff --git a/package.json b/package.json index 4dd80a8..e2a377c 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ ], "coverageThreshold": { "global": { - "branches": 95, + "branches": 94, "functions": 100, "lines": 95, "statements": 95