@graphty/graphty-element / catalog / listGraphs
Function: listGraphs() ​
listGraphs(
source):Promise<readonlyGraphListing[] |null>
Defined in: graphty-element/src/catalog/listGraphs.ts:80
List the graphs a file holds, so a host can offer a choice before loading one.
import { listGraphs } from "@graphty/graphty-element/catalog";
const graphs = await listGraphs({ config: { file } });
// [{ index: 0, name: "Network 1", nodes: 120, edges: 340 }, ...], or null
await element.loadFromFile(file, { graphIndex: 1 });Parameters ​
source ​
The source, as session.data.import takes it: an optional format type, and a config holding inline data (text, a Uint8Array or an ArrayBuffer), a file or a url. The format is detected, as a load detects it, when type is absent.
Returns ​
Promise<readonly GraphListing[] | null>
The graphs in file order, or null for a format whose file holds one graph.
Throws ​
A GraphtyError: E_BAD_COMMAND when the config has no data, file or url; E_UNKNOWN_FORMAT when the format is not recognised or not registered; E_FETCH_FAILED when the URL cannot be read; E_PARSE_FAILED when the file cannot be read.