# HG changeset patch # User drewp@bigasterisk.com # Date 1578558845 28800 # Node ID 490f569bb0c9d40b4c99d13114cacb7bd5e74d38 # Parent 77aa2e9234ed766dbc3b44aa1c0c2ca9392c3832 use Util.isFoo a little diff -r 77aa2e9234ed -r 490f569bb0c9 src/graph_view.ts --- 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;