---
title: "@vltpkg/graph-run: Reference — vlt docs"
description: "Documentation for the vlt client and the vlt registry."
url: "https://docs.vlt.io/client/api-reference/graph-run/reference"
image: "https://docs.vlt.io/og/client/api-reference/graph-run/reference"
lang: "en"
---

# Reference

## Classes

### Runner\<Node, Result>

Defined in: index.ts:370

Asynchronous graph runner

#### Extends

- [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o)<`Node`, `Result`, `false`, [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result)<`Node`, `Result`>>

#### Type Parameters

| Type Parameter |
| -------------- |
| `Node`         |
| `Result`       |

#### Constructors

##### new Runner()

```ts
new Runner<Node, Result>(options, from?): Runner<Node, Result>
```

Defined in: index.ts:201

###### Parameters

| Parameter | Type                                                                                                        |
| --------- | ----------------------------------------------------------------------------------------------------------- |
| `options` | [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result) |
| `from`?   | [`Callable`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#callable)                      |

###### Returns

[`Runner`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnernode-result)<`Node`, `Result`>

###### Inherited from

[`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`constructor`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#constructors-1)

#### Properties

| Property           | Type                                                                                                                    | Default value | Description                                                                                         | Inherited from                                                                                                                                                                                                        |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `dependents`       | `Map`<`Node`, `Set`<`Node`>>                                                                                            | `undefined`   | Set of dependents (direct & transitive) on each node                                                | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`dependents`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#dependents-1)             |
| `directDependents` | `Map`<`Node`, `Set`<`Node`>>                                                                                            | `undefined`   | Set of direct dependents on each node                                                               | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`directDependents`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#directdependents-1) |
| `errors`           | `unknown`\[]                                                                                                            | `[]`          | Rejections and Errors encountered in the traversal                                                  | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`errors`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#errors-1)                     |
| `failFast`         | `boolean`                                                                                                               | `undefined`   | True if we are in failFast mode                                                                     | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`failFast`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#failfast-1)                 |
| `from`             | [`Callable`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#callable)                                  | `undefined`   | Function defining the callsite where the traversal was initiated, used for Error.captureStackTrace. | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`from`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#from-1)                         |
| `options`          | [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result)             | `undefined`   | Options provided to constructor                                                                     | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`options`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#options-1)                   |
| `promiseWaiting`   | `Map`<`Node`, `Set`<`Node`>>                                                                                            | `undefined`   | Track which node's promise is waiting for which other nodes                                         | -                                                                                                                                                                                                                     |
| `results`          | `Map`<`Node`, `Result`>                                                                                                 | `undefined`   | The map of traversal results                                                                        | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`results`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#results-1)                   |
| `running`          | `Map`<`Node`, `Promise`<`void`>>                                                                                        | `undefined`   | Map of nodes currently awaiting completion                                                          | -                                                                                                                                                                                                                     |
| `settled`          | [`SettledMap`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#settledmapnode-result)<`Node`, `Result`> | `undefined`   | The map of PromiseSettledResult objects                                                             | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`settled`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#settled-1)                   |

#### Methods

##### getDeps()

```ts
getDeps(n): Promise<Node[]>
```

Defined in: index.ts:382

Get the dependencies of a given node

###### Parameters

| Parameter | Type   |
| --------- | ------ |
| `n`       | `Node` |

###### Returns

`Promise`<`Node`\[]>

###### Overrides

[`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`getDeps`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#getdeps-1)

##### onCycle()

```ts
onCycle(
   n, 
   cycle, 
path): Promise<void>
```

Defined in: index.ts:406

Calls the `options.onCycle()` method when a cycle is detected.

###### Parameters

| Parameter | Type      |
| --------- | --------- |
| `n`       | `Node`    |
| `cycle`   | `Node`\[] |
| `path`    | `Node`\[] |

###### Returns

`Promise`<`void`>

###### Overrides

[`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`onCycle`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#oncycle-1)

##### route()

```ts
route(n, d): undefined | [Node, ...path: Node[]]
```

Defined in: index.ts:264

For a Node `n` that depends directly or transitively on Node `d`, find the shortest known dependency path from `n` to `d`. This is done by walking backwards breadth-first up the dependency relations from `d` until `n` is found.

If no known path can be found, then `undefined` is returned. Otherwise, a path array is returned that starts with `n` and ends with `d`.

Note that self-referential links are never considered, since they're by definition cyclical.

###### Parameters

| Parameter | Type   |
| --------- | ------ |
| `n`       | `Node` |
| `d`       | `Node` |

###### Returns

`undefined` | \[`Node`, `...path: Node[]`]

###### Inherited from

[`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`route`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#route-1)

##### run()

```ts
run(): Promise<void>
```

Defined in: index.ts:507

Initiate the graph traversal, resolving/returning when complete

###### Returns

`Promise`<`void`>

###### Overrides

[`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`run`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#run-1)

##### visit()

```ts
visit(
   n, 
   path, 
depResults): Promise<Result>
```

Defined in: index.ts:397

Visit a node. Calls `options.visit()`

###### Parameters

| Parameter    | Type                                                                                                                    |
| ------------ | ----------------------------------------------------------------------------------------------------------------------- |
| `n`          | `Node`                                                                                                                  |
| `path`       | `Node`\[]                                                                                                               |
| `depResults` | [`DepResults`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#depresultsnode-result)<`Node`, `Result`> |

###### Returns

`Promise`<`Result`>

###### Overrides

[`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`visit`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#visit-1)

---

### `abstract` RunnerBase\<Node, Result, Sync, O>

Defined in: index.ts:151

Base class of Runner and RunnerSync

#### Extended by

- [`Runner`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnernode-result)
- [`RunnerSync`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnersyncnode-result)

#### Type Parameters

| Type Parameter                                                                                                                                                                                                                                                                                                | Default type                                                                                                                                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Node`                                                                                                                                                                                                                                                                                                        | -                                                                                                                                                                                                                                                                                               |
| `Result`                                                                                                                                                                                                                                                                                                      | `void`                                                                                                                                                                                                                                                                                          |
| `Sync` _extends_ `boolean`                                                                                                                                                                                                                                                                                    | `false`                                                                                                                                                                                                                                                                                         |
| `O` _extends_ `Sync` _extends_ `true` ? [`RunnerOptionsSync`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionssyncnode-result)<`Node`, `Result`> : [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result)<`Node`, `Result`> | `Sync` _extends_ `true` ? [`RunnerOptionsSync`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionssyncnode-result)<`Node`, `Result`> : [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result)<`Node`, `Result`> |

#### Constructors

##### new RunnerBase()

```ts
new RunnerBase<Node, Result, Sync, O>(options, from?): RunnerBase<Node, Result, Sync, O>
```

Defined in: index.ts:201

###### Parameters

| Parameter | Type                                                                                   |
| --------- | -------------------------------------------------------------------------------------- |
| `options` | `O`                                                                                    |
| `from`?   | [`Callable`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#callable) |

###### Returns

[`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o)<`Node`, `Result`, `Sync`, `O`>

#### Properties

| Property           | Type                                                                                                                    | Default value | Description                                                                                         |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------- |
| `dependents`       | `Map`<`Node`, `Set`<`Node`>>                                                                                            | `undefined`   | Set of dependents (direct & transitive) on each node                                                |
| `directDependents` | `Map`<`Node`, `Set`<`Node`>>                                                                                            | `undefined`   | Set of direct dependents on each node                                                               |
| `errors`           | `unknown`\[]                                                                                                            | `[]`          | Rejections and Errors encountered in the traversal                                                  |
| `failFast`         | `boolean`                                                                                                               | `undefined`   | True if we are in failFast mode                                                                     |
| `from`             | [`Callable`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#callable)                                  | `undefined`   | Function defining the callsite where the traversal was initiated, used for Error.captureStackTrace. |
| `options`          | `O`                                                                                                                     | `undefined`   | Options provided to constructor                                                                     |
| `results`          | `Map`<`Node`, `Result`>                                                                                                 | `undefined`   | The map of traversal results                                                                        |
| `settled`          | [`SettledMap`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#settledmapnode-result)<`Node`, `Result`> | `undefined`   | The map of PromiseSettledResult objects                                                             |

#### Methods

##### getDeps()

```ts
abstract getDeps(n): Sync extends true ? Node[] : Promise<Node[]>
```

Defined in: index.ts:232

Get the dependencies of a given node

###### Parameters

| Parameter | Type   |
| --------- | ------ |
| `n`       | `Node` |

###### Returns

`Sync` _extends_ `true` ? `Node`\[] : `Promise`<`Node`\[]>

##### onCycle()

```ts
abstract onCycle(
   n, 
   cycle, 
path): Sync extends true ? void : void | Promise<void>
```

Defined in: index.ts:246

Calls the `options.onCycle()` method when a cycle is detected.

###### Parameters

| Parameter | Type      |
| --------- | --------- |
| `n`       | `Node`    |
| `cycle`   | `Node`\[] |
| `path`    | `Node`\[] |

###### Returns

`Sync` _extends_ `true` ? `void` : `void` | `Promise`<`void`>

##### route()

```ts
route(n, d): undefined | [Node, ...path: Node[]]
```

Defined in: index.ts:264

For a Node `n` that depends directly or transitively on Node `d`, find the shortest known dependency path from `n` to `d`. This is done by walking backwards breadth-first up the dependency relations from `d` until `n` is found.

If no known path can be found, then `undefined` is returned. Otherwise, a path array is returned that starts with `n` and ends with `d`.

Note that self-referential links are never considered, since they're by definition cyclical.

###### Parameters

| Parameter | Type   |
| --------- | ------ |
| `n`       | `Node` |
| `d`       | `Node` |

###### Returns

`undefined` | \[`Node`, `...path: Node[]`]

##### run()

```ts
abstract run(): Sync extends true ? void : Promise<void>
```

Defined in: index.ts:229

Initiate the graph traversal, resolving/returning when complete

###### Returns

`Sync` _extends_ `true` ? `void` : `Promise`<`void`>

##### visit()

```ts
abstract visit(
   n, 
   path, 
depResults): Sync extends true ? Result : Promise<Result>
```

Defined in: index.ts:237

Visit a node. Calls `options.visit()`

###### Parameters

| Parameter    | Type                                                                                                                    |
| ------------ | ----------------------------------------------------------------------------------------------------------------------- |
| `n`          | `Node`                                                                                                                  |
| `path`       | `Node`\[]                                                                                                               |
| `depResults` | [`DepResults`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#depresultsnode-result)<`Node`, `Result`> |

###### Returns

`Sync` _extends_ `true` ? `Result` : `Promise`<`Result`>

---

### RunnerSync\<Node, Result>

Defined in: index.ts:517

Synchronous graph runner

#### Extends

- [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o)<`Node`, `Result`, `true`, [`RunnerOptionsSync`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionssyncnode-result)<`Node`, `Result`>>

#### Type Parameters

| Type Parameter |
| -------------- |
| `Node`         |
| `Result`       |

#### Constructors

##### new RunnerSync()

```ts
new RunnerSync<Node, Result>(options, from?): RunnerSync<Node, Result>
```

Defined in: index.ts:201

###### Parameters

| Parameter | Type                                                                                                                |
| --------- | ------------------------------------------------------------------------------------------------------------------- |
| `options` | [`RunnerOptionsSync`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionssyncnode-result) |
| `from`?   | [`Callable`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#callable)                              |

###### Returns

[`RunnerSync`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnersyncnode-result)<`Node`, `Result`>

###### Inherited from

[`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`constructor`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#constructors-1)

#### Properties

| Property           | Type                                                                                                                    | Default value | Description                                                                                         | Inherited from                                                                                                                                                                                                        |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `dependents`       | `Map`<`Node`, `Set`<`Node`>>                                                                                            | `undefined`   | Set of dependents (direct & transitive) on each node                                                | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`dependents`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#dependents-1)             |
| `directDependents` | `Map`<`Node`, `Set`<`Node`>>                                                                                            | `undefined`   | Set of direct dependents on each node                                                               | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`directDependents`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#directdependents-1) |
| `errors`           | `unknown`\[]                                                                                                            | `[]`          | Rejections and Errors encountered in the traversal                                                  | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`errors`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#errors-1)                     |
| `failFast`         | `boolean`                                                                                                               | `undefined`   | True if we are in failFast mode                                                                     | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`failFast`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#failfast-1)                 |
| `from`             | [`Callable`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#callable)                                  | `undefined`   | Function defining the callsite where the traversal was initiated, used for Error.captureStackTrace. | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`from`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#from-1)                         |
| `options`          | [`RunnerOptionsSync`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionssyncnode-result)     | `undefined`   | Options provided to constructor                                                                     | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`options`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#options-1)                   |
| `results`          | `Map`<`Node`, `Result`>                                                                                                 | `undefined`   | The map of traversal results                                                                        | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`results`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#results-1)                   |
| `settled`          | [`SettledMap`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#settledmapnode-result)<`Node`, `Result`> | `undefined`   | The map of PromiseSettledResult objects                                                             | [`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`settled`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#settled-1)                   |

#### Methods

##### getDeps()

```ts
getDeps(n): Node[]
```

Defined in: index.ts:523

Get the dependencies of a given node

###### Parameters

| Parameter | Type   |
| --------- | ------ |
| `n`       | `Node` |

###### Returns

`Node`\[]

###### Overrides

[`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`getDeps`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#getdeps-1)

##### onCycle()

```ts
onCycle(
   n, 
   cycle, 
   path): void
```

Defined in: index.ts:533

Calls the `options.onCycle()` method when a cycle is detected.

###### Parameters

| Parameter | Type      |
| --------- | --------- |
| `n`       | `Node`    |
| `cycle`   | `Node`\[] |
| `path`    | `Node`\[] |

###### Returns

`void`

###### Overrides

[`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`onCycle`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#oncycle-1)

##### route()

```ts
route(n, d): undefined | [Node, ...path: Node[]]
```

Defined in: index.ts:264

For a Node `n` that depends directly or transitively on Node `d`, find the shortest known dependency path from `n` to `d`. This is done by walking backwards breadth-first up the dependency relations from `d` until `n` is found.

If no known path can be found, then `undefined` is returned. Otherwise, a path array is returned that starts with `n` and ends with `d`.

Note that self-referential links are never considered, since they're by definition cyclical.

###### Parameters

| Parameter | Type   |
| --------- | ------ |
| `n`       | `Node` |
| `d`       | `Node` |

###### Returns

`undefined` | \[`Node`, `...path: Node[]`]

###### Inherited from

[`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`route`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#route-1)

##### run()

```ts
run(): Map<Node, Result>
```

Defined in: index.ts:571

Initiate the graph traversal, resolving/returning when complete

###### Returns

`Map`<`Node`, `Result`>

###### Overrides

[`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`run`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#run-1)

##### visit()

```ts
visit(
   n, 
   path, 
   depResults): Result
```

Defined in: index.ts:528

Visit a node. Calls `options.visit()`

###### Parameters

| Parameter    | Type                                                                                                                    |
| ------------ | ----------------------------------------------------------------------------------------------------------------------- |
| `n`          | `Node`                                                                                                                  |
| `path`       | `Node`\[]                                                                                                               |
| `depResults` | [`DepResults`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#depresultsnode-result)<`Node`, `Result`> |

###### Returns

`Result`

###### Overrides

[`RunnerBase`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runnerbasenode-result-sync-o).[`visit`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#visit-1)

## Interfaces

### RunnerOptions\<Node, Result>

Defined in: index.ts:63

Options that define the graph and how to traverse it

#### Extended by

- [`RunnerOptionsSync`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionssyncnode-result)

#### Type Parameters

| Type Parameter | Default type |
| -------------- | ------------ |
| `Node`         | -            |
| `Result`       | `void`       |

#### Properties

| Property    | Type                                                                                                                                                                                                                                   | Description                                                                                                                                                                                                                                                                                                                                              |
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `failFast?` | `boolean`                                                                                                                                                                                                                              | Set to `false` to continue operations even if errors occur. If set to false, then an AggregateError will be raised on failure containing all failures (even if only one). If true, then a normal Error will be raised on failure. **Default** `true`                                                                                                     |
| `getDeps`   | (`node`: `Node`) => `Node`\[] \| `Promise`<`Node`\[]>                                                                                                                                                                                  | get the dependencies of a given node                                                                                                                                                                                                                                                                                                                     |
| `graph`     | \[`Node`, `...rest: Node[]`]                                                                                                                                                                                                           | Array of one or more entry nodes.                                                                                                                                                                                                                                                                                                                        |
| `onCycle?`  | (`node`: `Node`, `cycle`: `Node`\[], `path`: `Node`\[]) => `void` \| `Promise`<`void`>                                                                                                                                                 | Called when a cycle is encountered. Throw in this method to enforce a DAG graph. If left undefined, then cycles are silently ignored and skipped. `node` parameter is the dependency that is being skipped. `cycle` is the route from the dependent back to itself via the parent. `path` is the path to the dependent who wanted this dep to be loaded. |
| `signal?`   | `AbortSignal`                                                                                                                                                                                                                          | a signal that will trigger the graph traversal to end prematurely                                                                                                                                                                                                                                                                                        |
| `visit`     | (`node`: `Node`, `signal`: `AbortSignal`, `path`: `Node`\[], `depResults`: [`DepResults`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#depresultsnode-result)<`Node`, `Result`>) => `Result` \| `Promise`<`Result`> | action to take on each node                                                                                                                                                                                                                                                                                                                              |

---

### RunnerOptionsSync\<Node, Result>

Defined in: index.ts:118

Options that can define a synchronous graph traversal.

Note that if the visit() method is async, then the _promises themselves_ will be used as the `Result` type, which is likely not what you want!

#### Extends

- [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result)<`Node`, `Result`>

#### Type Parameters

| Type Parameter | Default type |
| -------------- | ------------ |
| `Node`         | -            |
| `Result`       | `void`       |

#### Properties

| Property    | Type                                                                                                                                                                                                            | Description                                                                                                                                                                                                                                          | Overrides                                                                                                                                                                                          | Inherited from                                                                                                                                                                                       |
| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `failFast?` | `boolean`                                                                                                                                                                                                       | Set to `false` to continue operations even if errors occur. If set to false, then an AggregateError will be raised on failure containing all failures (even if only one). If true, then a normal Error will be raised on failure. **Default** `true` | -                                                                                                                                                                                                  | [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result).[`failFast`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#failfast-3) |
| `getDeps`   | (`node`: `Node`) => `Node`\[]                                                                                                                                                                                   | Get a set of dependency nodes synchronously                                                                                                                                                                                                          | [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result).[`getDeps`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#getdeps-3) | -                                                                                                                                                                                                    |
| `graph`     | \[`Node`, `...rest: Node[]`]                                                                                                                                                                                    | Array of one or more entry nodes.                                                                                                                                                                                                                    | -                                                                                                                                                                                                  | [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result).[`graph`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#graph)         |
| `onCycle?`  | (`node`: `Node`, `cycle`: `Node`\[], `path`: `Node`\[]) => `void`                                                                                                                                               | Handle cycles synchronously                                                                                                                                                                                                                          | [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result).[`onCycle`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#oncycle-3) | -                                                                                                                                                                                                    |
| `signal?`   | `AbortSignal`                                                                                                                                                                                                   | a signal that will trigger the graph traversal to end prematurely                                                                                                                                                                                    | -                                                                                                                                                                                                  | [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result).[`signal`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#signal)       |
| `visit`     | (`node`: `Node`, `signal`: `AbortSignal`, `path`: `Node`\[], `depResults`: [`DepResults`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#depresultsnode-result)<`Node`, `Result`>) => `Result` | Visit a node synchronously                                                                                                                                                                                                                           | [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result).[`visit`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#visit-3)     | -                                                                                                                                                                                                    |

## Type Aliases

### Callable

```ts
type Callable = Function | (...a) => unknown | (...a) => unknown;
```

Defined in: index.ts:144

Any function or class. Used for Error.captureStackTrace

---

### DepResults\<Node, Result>

```ts
type DepResults<Node, Result> = Map<Node, Result | undefined>;
```

Defined in: index.ts:110

#### Type Parameters

| Type Parameter |
| -------------- |
| `Node`         |
| `Result`       |

---

### ErrorCause\<Node>

```ts
type ErrorCause<Node> = object & 
  | {
  code: "GRAPHRUN_NO_NODES";
  found: unknown;
  wanted: string;
 }
  | {
  code: "GRAPHRUN_CYCLE_WITHOUT_PATH";
 }
  | {
  cause: Error;
  code: "GRAPHRUN_TRAVERSAL";
  node: Node;
  path: Node[];
};
```

Defined in: index.ts:23

#### Type declaration

| Name   | Type                                                                                     |
| ------ | ---------------------------------------------------------------------------------------- |
| `code` | [`ErrorCode`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#errorcode) |

#### Type Parameters

| Type Parameter |
| -------------- |
| `Node`         |

---

### ErrorCode

```ts
type ErrorCode = 
  | "GRAPHRUN_NO_NODES"
  | "GRAPHRUN_CYCLE_WITHOUT_PATH"
  | "GRAPHRUN_TRAVERSAL";
```

Defined in: index.ts:18

Codes indicating the type of error that was encountered. These are found on the `Error.cause.code` field.

They are:

- `'GRAPHRUN_TRAVERSAL'` The command run on a given node has failed, either by throwing an error, or by returning a rejected promise.
- `'GRAPHRUN_NO_NODES'` An empty list of initial nodes was provided to the graph run operation. At least one starting node must be present in the list.
- `'GRAPHRUN_CYCLE_WITHOUT_PATH'` - A cycle in the graph was detected, but the path _to_ the node where the cycle was detected could not be determined. This is impossible, and cannot ever happen.

---

### SettledMap\<Node, Result>

```ts
type SettledMap<Node, Result> = Map<Node, PromiseSettledResult<Result>>;
```

Defined in: index.ts:138

A map of nodes to their PromiseSettledResult value

#### Type Parameters

| Type Parameter | Default type |
| -------------- | ------------ |
| `Node`         | -            |
| `Result`       | `void`       |

## Functions

### allSettled()

```ts
function allSettled<Node, Result>(options): Promise<SettledMap<Node, Result>>
```

Defined in: index.ts:629

Asynchronous graph traversal, capturing all error/result statuses.

#### Type Parameters

| Type Parameter |
| -------------- |
| `Node`         |
| `Result`       |

#### Parameters

| Parameter | Type                                                                                                                          |
| --------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `options` | [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result)<`Node`, `Result`> |

#### Returns

`Promise`<[`SettledMap`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#settledmapnode-result)<`Node`, `Result`>>

---

### allSettledSync()

```ts
function allSettledSync<Node, Result>(options): SettledMap<Node, Result>
```

Defined in: index.ts:644

Synchronous graph traversal, capturing all error/result statuses.

#### Type Parameters

| Type Parameter |
| -------------- |
| `Node`         |
| `Result`       |

#### Parameters

| Parameter | Type                                                                                                                                  |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `options` | [`RunnerOptionsSync`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionssyncnode-result)<`Node`, `Result`> |

#### Returns

[`SettledMap`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#settledmapnode-result)<`Node`, `Result`>

---

### any()

```ts
function any<Node, Result>(options): Promise<Result>
```

Defined in: index.ts:660

Asynchronous graph traversal, returning the first successful visit. If all visits fail, then an AggregateError is raised with all errors encountered.

#### Type Parameters

| Type Parameter |
| -------------- |
| `Node`         |
| `Result`       |

#### Parameters

| Parameter | Type                                                                                                                          |
| --------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `options` | [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result)<`Node`, `Result`> |

#### Returns

`Promise`<`Result`>

---

### anySync()

```ts
function anySync<Node, Result>(options): Result
```

Defined in: index.ts:700

Synchronous graph traversal, returning the first successful visit. If all visits fail, then an AggregateError is thrown with all errors encountered.

#### Type Parameters

| Type Parameter |
| -------------- |
| `Node`         |
| `Result`       |

#### Parameters

| Parameter | Type                                                                                                                                  |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `options` | [`RunnerOptionsSync`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionssyncnode-result)<`Node`, `Result`> |

#### Returns

`Result`

---

### graphRun()

```ts
function graphRun<Node, Result>(options): Promise<Map<Node, Result>>
```

Defined in: index.ts:586

Asynchronous graph traversal method

If `failFast:false` is set in the options, then an AggregateError will be raised if there were any failures. Otherwise, a normal Error is raised on failure.

#### Type Parameters

| Type Parameter |
| -------------- |
| `Node`         |
| `Result`       |

#### Parameters

| Parameter | Type                                                                                                                          |
| --------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `options` | [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result)<`Node`, `Result`> |

#### Returns

`Promise`<`Map`<`Node`, `Result`>>

---

### graphRunSync()

```ts
function graphRunSync<Node, Result>(options): Map<Node, Result>
```

Defined in: index.ts:609

Synchronous graph traversal method

If `failFast:false` is set in the options, then an AggregateError will be thrown if there were any failures. Otherwise, a normal Error is thrown on failure.

#### Type Parameters

| Type Parameter |
| -------------- |
| `Node`         |
| `Result`       |

#### Parameters

| Parameter | Type                                                                                                                                  |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `options` | [`RunnerOptionsSync`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionssyncnode-result)<`Node`, `Result`> |

#### Returns

`Map`<`Node`, `Result`>

---

### isGraphRunError()

```ts
function isGraphRunError<Node>(er): er is Error & { cause: ErrorCause<Node> }
```

Defined in: index.ts:40

#### Type Parameters

| Type Parameter |
| -------------- |
| `Node`         |

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `er`      | `unknown` |

#### Returns

`er is Error & { cause: ErrorCause<Node> }`

---

### race()

```ts
function race<Node, Result>(options): Promise<Result>
```

Defined in: index.ts:739

Asynchronous graph traversal, resolving or rejecting when the first visit resolves or rejects.

#### Type Parameters

| Type Parameter |
| -------------- |
| `Node`         |
| `Result`       |

#### Parameters

| Parameter | Type                                                                                                                          |
| --------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `options` | [`RunnerOptions`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionsnode-result)<`Node`, `Result`> |

#### Returns

`Promise`<`Result`>

---

### raceSync()

```ts
function raceSync<Node, Result>(options): Result
```

Defined in: index.ts:768

Synchronous graph traversal, returning or throwing when the first visit is completed.

#### Type Parameters

| Type Parameter |
| -------------- |
| `Node`         |
| `Result`       |

#### Parameters

| Parameter | Type                                                                                                                                  |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `options` | [`RunnerOptionsSync`](https://docs.vlt.io/client/api-reference/graph-run/reference.md#runneroptionssyncnode-result)<`Node`, `Result`> |

#### Returns

`Result`
