basant307/AI_Governance_Project
045
1'use strict';2 3exports.__esModule = true;4 5/** @type {import('./visit').default} */6exports.default = function visit(node, keys, visitorSpec) {7 if (!node || !keys) {8 return;9 }10 const type = node.type;11 const visitor = visitorSpec[type];12 if (typeof visitor === 'function') {13 visitor(node);14 }15 const childFields = keys[type];16 if (!childFields) {17 return;18 }19 childFields.forEach((fieldName) => {20 // @ts-expect-error TS sucks with concat21 [].concat(node[fieldName]).forEach((item) => {22 visit(item, keys, visitorSpec);23 });24 });25 26 const exit = visitorSpec[`${type}:Exit`];27 if (typeof exit === 'function') {28 exit(node);29 }30};31 