A graph that contains a type field ObjectWithTypeField in its node attributes.
A string for a single type, or object or array for multiple types.
The graph to retrieve nodes from.
The types of nodes to retrieve.
An array if a string was provided for the types (single result), or an object of arrays if an object or array was provided for the types (multiple results). The node type is inferred from the node's type attribute if it was specified using a literal string.
type LanguageAttributes = {
_type: "language"
country: string
}
type CountryAttributes = {
_type: "country"
continent: string
}
type StringResult = NodeEntry<CountryAttributes>[]
type ArrayOrObjectResult = {
language: NodeEntry<LanguageAttributes>[]
country: NodeEntry<CountryAttributes>[]
}
const graph = new Graph<LanguageAttributes | CountryAttributes>()
// After adding nodes...
// StringResult is inferred
const result = getGraphNodesOfType(graph, "country")
// ArrayOrObjectResult is inferred
const result2 = getGraphNodesOfType(graph, ["language", "country"])
// ArrayOrObjectResult is inferred
const result3 = getGraphNodesOfType(graph, {
language: true,
country: true,
})
Generated using TypeDoc
Retrieves graph nodes of a specific type from the given graph.