# HG changeset patch # User drewp@bigasterisk.com # Date 1578902796 28800 # Node ID 601a604c097aa58405ba275b2fb49a0b5c79b89a # Parent 490f569bb0c9d40b4c99d13114cacb7bd5e74d38 new module with getStringValue diff -r 490f569bb0c9 -r 601a604c097a src/graph_queries.ts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/graph_queries.ts Mon Jan 13 00:06:36 2020 -0800 @@ -0,0 +1,18 @@ +import { N3Store, NamedNode } from "n3"; + +export function getStringValue( + store: N3Store | undefined, + subj: NamedNode, + pred: NamedNode, + defaultValue: string = "" +): string { + if (store === undefined) { + // this is so you can use the function before you have a graph + return "..."; + } + const objs = store.getObjects(subj, pred, null); + if (objs.length == 0) { + return defaultValue; + } + return objs[0].value; +} diff -r 490f569bb0c9 -r 601a604c097a src/index.ts --- a/src/index.ts Thu Jan 09 00:34:05 2020 -0800 +++ b/src/index.ts Mon Jan 13 00:06:36 2020 -0800 @@ -7,6 +7,7 @@ import { StreamedGraphClient } from "./streamed_graph_client"; import style from "./style.styl"; +export * from "./graph_queries"; export interface VersionedGraph { version: number;