MCPcopy Create free account
hub / github.com/codemix/graph / getAll

Method getAll

packages/graph/src/Traversals.ts:233–245  ·  view source on GitHub ↗

* Get all the node in the path by label. * @param label The label to get the nodes by.

(
    label: TLabel,
  )

Source from the content-addressed store, hash-verified

231 * @param label The label to get the nodes by.
232 */
233 public getAll<const TLabel extends string>(
234 label: TLabel,
235 ): GetAllTraversalPathsByLabel<TraversalPath<TParent, TValue, TLabels>, TLabel> {
236 const nodes = [] as TraversalPath<any, any, any>[];
237 let node: TraversalPath<any, any, any> = this;
238 while (node !== undefined) {
239 if (node.labels.includes(label)) {
240 nodes.unshift(node);
241 }
242 node = node.parent;
243 }
244 return nodes as GetAllTraversalPathsByLabel<TraversalPath<TParent, TValue, TLabels>, TLabel>;
245 }
246
247 public toJSON(): TraversalPathJSON {
248 return {

Callers 1

traverseMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected