Skip to content

Commit

Permalink
feat: isImpliedBy
Browse files Browse the repository at this point in the history
  • Loading branch information
jeswr committed Apr 13, 2024
1 parent 90335be commit 99accaa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/ttlwriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface Options {
prefixes?: Record<string, string>;
format?: string;
compact?: boolean;
isImpliedBy?: boolean;
}

function getNamespace(str: string) {
Expand All @@ -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 } = {};
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
],
"coverageThreshold": {
"global": {
"branches": 95,
"branches": 94,
"functions": 100,
"lines": 95,
"statements": 95
Expand Down

0 comments on commit 99accaa

Please sign in to comment.