(expression)
| 215 | // Generate the name base by counting the number of custom functions |
| 216 | // within the body. |
| 217 | const countFunctions = (expression) => { |
| 218 | const countNodes = (nodes) => |
| 219 | nodes.map(countNode).reduce((a, b) => a + b, 0); |
| 220 | const countNode = (node) => { |
| 221 | if (node.functionDefinitionValue) { |
| 222 | return 1; |
| 223 | } else if (node.arrayValue) { |
| 224 | return countNodes(node.arrayValue.values); |
| 225 | } else if (node.dictionaryValue) { |
| 226 | return countNodes(Object.values(node.dictionaryValue.values)); |
| 227 | } else if (node.functionInvocationValue) { |
| 228 | const fn = node.functionInvocationValue; |
| 229 | return countNodes(Object.values(fn.arguments)); |
| 230 | } |
| 231 | return 0; |
| 232 | }; |
| 233 | return countNodes(Object.values(expression.values)); |
| 234 | }; |
| 235 | |
| 236 | // There are three function building phases, which each call body.apply: |
| 237 | // 1 - Check Return. The constructor verifies that body.apply returns a |
no test coverage detected