Returns a deep annotated copy of the input node with annotations if it is a valid estree-sentry program. Throws a EstreeSentrySyntaxError if the input node is not a valid estree-sentry program. See guard for a failing example.
EstreeSentrySyntaxError
guard
import { ROOT_PATH, annotateProgram } from "estree-sentry";// returns: {// type: "Program",// sourceType: "script",// body: [{// type: "EmptyStatement",// path: "$.body.0",// kind: "Statement",// }],// path: "$",// kind: "Program"// }annotateProgram( { type: "Program", sourceType: "script", body: [ { type: "EmptyStatement", }, ], }, ROOT_PATH, (_node, path, kind) => ({ path, kind }),); Copy
import { ROOT_PATH, annotateProgram } from "estree-sentry";// returns: {// type: "Program",// sourceType: "script",// body: [{// type: "EmptyStatement",// path: "$.body.0",// kind: "Statement",// }],// path: "$",// kind: "Program"// }annotateProgram( { type: "Program", sourceType: "script", body: [ { type: "EmptyStatement", }, ], }, ROOT_PATH, (_node, path, kind) => ({ path, kind }),);
An EstreeSentrySyntaxError if the input root node is not a valid estree-sentry program.
The type of the annotation.
The input root node.
The root path to which segments will be appended.
Annotation function that will be called on each visited node.
A deep copy of the input root node that is a valid estree-sentry program.
Returns a deep annotated copy of the input node with annotations if it is a valid estree-sentry program. Throws a
EstreeSentrySyntaxError
if the input node is not a valid estree-sentry program. Seeguard
for a failing example.Example
Throws
An
EstreeSentrySyntaxError
if the input root node is not a valid estree-sentry program.