( program: Program )
| 1046 | parseCode("validators.js", code, {}).program |
| 1047 | |
| 1048 | const exportedFunctionsOf = ( |
| 1049 | program: Program |
| 1050 | ): Map<string, Node | undefined> => { |
| 1051 | const declared = new Map<string, Node>() |
| 1052 | const result = new Map<string, Node | undefined>() |
| 1053 | for (const statement of program.body) { |
| 1054 | if (statement.type === "FunctionDeclaration" && statement.id) |
| 1055 | declared.set(statement.id.name, statement) |
| 1056 | else if (statement.type === "VariableDeclaration") { |
| 1057 | for (const { id, init } of statement.declarations) { |
| 1058 | if (id.type === "Identifier" && init) |
| 1059 | declared.set(id.name, unwrapParentheses(init)) |
| 1060 | } |
| 1061 | } else if (statement.type === "ExportNamedDeclaration") { |
| 1062 | for (const specifier of statement.specifiers) { |
| 1063 | result.set( |
| 1064 | exportNameOf(specifier.exported), |
| 1065 | specifier.local.type === "Identifier" ? |
| 1066 | declared.get(specifier.local.name) |
| 1067 | : undefined |
| 1068 | ) |
| 1069 | } |
| 1070 | } |
| 1071 | } |
| 1072 | return result |
| 1073 | } |
| 1074 | |
| 1075 | const unwrapParentheses = (node: Node): Node => |
| 1076 | node.type === "ParenthesizedExpression" ? |
no test coverage detected