changeset 52:490f569bb0c9

use Util.isFoo a little
author drewp@bigasterisk.com
date Thu, 09 Jan 2020 00:34:05 -0800
parents 77aa2e9234ed
children 601a604c097a
files src/graph_view.ts
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/graph_view.ts	Thu Jan 09 00:33:46 2020 -0800
+++ b/src/graph_view.ts	Thu Jan 09 00:34:05 2020 -0800
@@ -1,5 +1,5 @@
 import { html, TemplateResult } from "lit-html";
-import { Quad, Term, N3Store } from "n3";
+import { Quad, Term, N3Store, Literal } from "n3";
 import { DataFactory, Util } from "n3";
 const { namedNode } = DataFactory;
 import * as RDF from "rdf-js";
@@ -71,7 +71,8 @@
     this.labels = labels;
   }
   getHtml(n: Term | NamedNode): TemplateResult {
-    if (n.termType == "Literal") {
+    if (Util.isLiteral(n)) {
+      n = n as Literal;
       let dtPart: any = "";
       if (n.datatype) {
         dtPart = html`
@@ -85,7 +86,8 @@
       `;
     }
 
-    if (n.termType == "NamedNode") {
+    if (Util.isNamedNode(n)) {
+      n = n as NamedNode;
       let shortened = false;
       let uriValue: string = n.value;
       for (let [long, short] of [
@@ -94,7 +96,7 @@
         ["http://purl.org/dc/elements/1.1/", "dc:"],
         ["http://www.w3.org/2001/XMLSchema#", "xsd:"]
       ]) {
-        if (uriValue?.startsWith(long)) {
+        if (uriValue.startsWith(long)) {
           uriValue = short + uriValue.substr(long.length);
           shortened = true;
           break;