1 line
2.2 KiB
Plaintext
1 line
2.2 KiB
Plaintext
{"version":3,"names":["VISITOR_KEYS","traverseNode","node","opts","scope","state","path","skipKeys","keys","type","context","TraversalContext","key","visit"],"sources":["../src/traverse-node.ts"],"sourcesContent":["import TraversalContext from \"./context\";\nimport type { TraverseOptions } from \"./index\";\nimport type NodePath from \"./path\";\nimport type Scope from \"./scope\";\nimport type * as t from \"@babel/types\";\nimport { VISITOR_KEYS } from \"@babel/types\";\n\n/**\n * Traverse the children of given node\n * @param {Node} node\n * @param {TraverseOptions} opts The traverse options used to create a new traversal context\n * @param {scope} scope A traversal scope used to create a new traversal context. When opts.noScope is true, scope should not be provided\n * @param {any} state A user data storage provided as the second callback argument for traversal visitors\n * @param {NodePath} path A NodePath of given node\n * @param {Record<string, boolean>} skipKeys A map from key names to whether that should be skipped during traversal. The skipKeys are applied to every descendants\n * @returns {boolean} Whether the traversal stops early\n\n * @note This function does not visit the given `node`.\n */\nexport function traverseNode(\n node: t.Node,\n opts: TraverseOptions,\n scope?: Scope,\n state?: any,\n path?: NodePath,\n skipKeys?: Record<string, boolean>,\n): boolean {\n const keys = VISITOR_KEYS[node.type];\n if (!keys) return false;\n\n const context = new TraversalContext(scope, opts, state, path);\n for (const key of keys) {\n if (skipKeys && skipKeys[key]) continue;\n if (context.visit(node, key)) {\n return true;\n }\n }\n\n return false;\n}\n"],"mappings":";;;;;;;AAAA;;AAKA;;;EAASA;;;AAcF,SAASC,YAAT,CACLC,IADK,EAELC,IAFK,EAGLC,KAHK,EAILC,KAJK,EAKLC,IALK,EAMLC,QANK,EAOI;EACT,MAAMC,IAAI,GAAGR,YAAY,CAACE,IAAI,CAACO,IAAN,CAAzB;EACA,IAAI,CAACD,IAAL,EAAW,OAAO,KAAP;EAEX,MAAME,OAAO,GAAG,IAAIC,gBAAJ,CAAqBP,KAArB,EAA4BD,IAA5B,EAAkCE,KAAlC,EAAyCC,IAAzC,CAAhB;;EACA,KAAK,MAAMM,GAAX,IAAkBJ,IAAlB,EAAwB;IACtB,IAAID,QAAQ,IAAIA,QAAQ,CAACK,GAAD,CAAxB,EAA+B;;IAC/B,IAAIF,OAAO,CAACG,KAAR,CAAcX,IAAd,EAAoBU,GAApB,CAAJ,EAA8B;MAC5B,OAAO,IAAP;IACD;EACF;;EAED,OAAO,KAAP;AACD"} |