# Class PathUtils

This class contains functions which convert TargetStates, Nodes and paths from one type to another.

- Defined in router/path/path-utils.js:16

#####
Index

### Constructors

constructor

### Methods

applyViewConfigs
buildPath
buildToPath
equals
inheritParams
makeTargetState
matching
nonDynamicParams
paramValues
subPath
treeChanges

##
Constructors

### constructor

- new PathUtils(): PathUtils

- #### Returns PathUtils

##
Methods

### `Static` applyViewConfigs

- applyViewConfigs($view, path, states): void

- Creates ViewConfig objects and adds to nodes.

  On each [[PathNode]], creates ViewConfig objects from the views: property of the node's state

  #### Parameters

  - $view: any
  - path: any
  - states: any

  #### Returns void

  - Defined in router/path/path-utils.js:50

### `Static` buildPath

- buildPath(targetState): any

- #### Parameters

  - targetState: any

  #### Returns any

  - Defined in router/path/path-utils.js:27

### `Static` buildToPath

- buildToPath(fromPath, targetState): any

- Given a fromPath: PathNode[] and a TargetState, builds a toPath: PathNode[]

  #### Parameters

  - fromPath: any
  - targetState: any

  #### Returns any

  - Defined in router/path/path-utils.js:34

### `Static` equals

- equals(pathA, pathB, paramsFn): boolean

- Returns true if two paths are identical.

  #### Parameters

  - pathA: any
  - pathB: any
  - paramsFn: any

    a function which returns the parameters to consider when comparing

  #### Returns boolean

  true if the the states and parameter values for both paths are identical

  - Defined in router/path/path-utils.js:172

### `Static` inheritParams

- inheritParams(fromPath, toPath, toKeys?): any

- Given a fromPath and a toPath, returns a new to path which inherits parameters from the fromPath

  For a parameter in a node to be inherited from the from path:

  - The toPath's node must have a matching node in the fromPath (by state).
  - The parameter name must not be found in the toKeys parameter array.

  Note: the keys provided in toKeys are intended to be those param keys explicitly specified by some caller, for instance, $state.transitionTo(..., toParams). If a key was found in toParams, it is not inherited from the fromPath.

  #### Parameters

  - fromPath: any
  - toPath: any
  - toKeys: any[] = []

  #### Returns any

  - Defined in router/path/path-utils.js:74

### `Static` makeTargetState

- makeTargetState(registry, path): TargetState

- Given a PathNode[], create an TargetState

  #### Parameters

  - registry: any
  - path: any

  #### Returns TargetState

  - Defined in router/path/path-utils.js:18

### `Static` matching

- matching(pathA, pathB, paramsFn): any[]

- Returns a new path which is: the subpath of the first path which matches the second path.

  The new path starts from root and contains any nodes that match the nodes in the second path. It stops before the first non-matching node.

  Nodes are compared using their state property and their parameter values. If a `paramsFn` is provided, only the [[Param]] returned by the function will be considered when comparing nodes.

  #### Parameters

  - pathA: any

    the first path

  - pathB: any

    the second path

  - paramsFn: any

    a function which returns the parameters to consider when comparing

  #### Returns any[]

  an array of PathNodes from the first path which match the nodes in the second path

  - Defined in router/path/path-utils.js:156

### `Static` nonDynamicParams

- nonDynamicParams(node): any

- #### Parameters

  - node: any

  #### Returns any

  - Defined in router/path/path-utils.js:194

### `Static` paramValues

- paramValues(path): any

- Gets the raw parameter values from a path

  #### Parameters

  - path: any

  #### Returns any

  - Defined in router/path/path-utils.js:201

### `Static` subPath

- subPath(path, predicate): any

- Return a subpath of a path, which stops at the first matching node

  Given an array of nodes, returns a subset of the array starting from the first node, stopping when the first node matches the predicate.

  #### Parameters

  - path: any

    a path of [[PathNode]]s

  - predicate: any

    a [[Predicate]] fn that matches [[PathNode]]s

  #### Returns any

  a subpath up to the matching node, or undefined if no match is found

  - Defined in router/path/path-utils.js:188

### `Static` treeChanges

- treeChanges(fromPath, toPath, reloadState): {
  entering: any;
  exiting: any;
  from: any;
  retained: any;
  retainedWithToParams: any;
  to: any;
  }

- Computes the tree changes (entering, exiting) between a fromPath and toPath.

  #### Parameters

  - fromPath: any
  - toPath: any
  - reloadState: any

  #### Returns {
  entering: any;
  exiting: any;
  from: any;
  retained: any;
  retainedWithToParams: any;
  to: any;
  }

  - ##### entering: any

  - ##### exiting: any

  - ##### from: any

  - ##### retained: any

  - ##### retainedWithToParams: any

  - ##### to: any

  - Defined in router/path/path-utils.js:113