Class: Walker

Services.Walker

new Walker(data, propExpression)

Traverses an object based on the property expression. Given a property expression, this will recursively evaluate each property within the expression until all properties have been evaluated.
Parameters:
Name Type Description
data object Object being traversed
propExpression string A string containing a property expression to evaluate
Source:

Members

(inner) isPrimitive

Determines which object is a primitive type
Source:

(inner) targetKey

The current key in an expression to evaluate
Source:

(inner) targetProps

The keys in a property expression that must be processed
Source:

(inner) useIndex

Flag to indicate whether to retrieve a value from an array using its number based index or an objects key within an array
Source:

Methods

(static) find(obj, props)

Recursively walks an object to reach the property expression. Continuing from our example in the parseKeys() method below, assume we start with the following expression: 'd.name in pets.dogs'
targetKey => 'name'
targetProps => ['pets', 'dogs']

This method will evaluate each property in the targetProps array against the current obj (on first iteration) or against the preceding expression evaluation until all have been processed. Once at the end, we evalute the targetKey against the last targetProp. So in this case, we would end up evaluation the `name` property in an object within a dogs array.
Parameters:
Name Type Description
obj object Object to traverse
props props Array of split property expressions.
Source: