Fetches a node or an array of nodes from a root node or an array of root nodes by following the segments of a path. Returns null if the target could not be found.
import { walkPath, VariableName } from "estree-sentry";// returns: { type: 'Identifier', name: 'x' }walkPath(["left", "argument"], { type: "LogicalExpression", operator: "&&", left: { type: "UnaryExpression", prefix: true, operator: "!", argument: { type: "Identifier", name: "x" as VariableName, }, }, right: { type: "Identifier", name:"y" as VariableName, },}); Copy
import { walkPath, VariableName } from "estree-sentry";// returns: { type: 'Identifier', name: 'x' }walkPath(["left", "argument"], { type: "LogicalExpression", operator: "&&", left: { type: "UnaryExpression", prefix: true, operator: "!", argument: { type: "Identifier", name: "x" as VariableName, }, }, right: { type: "Identifier", name:"y" as VariableName, },});
Annotation type
An array of segments which can be produced by splitPath.
splitPath
The root node or an array of root nodes from which to start walking the path.
The target node or an array of target nodes if found, otherwise null.
null
Fetches a node or an array of nodes from a root node or an array of root nodes by following the segments of a path. Returns null if the target could not be found.
Example