* Get visitor keys of a given node. * @param {external:AST} node The AST node to get keys. * @param {ESQueryOptions|undefined} options * @returns {string[]} Visitor keys of the node.
(node, options)
| 395 | * @returns {string[]} Visitor keys of the node. |
| 396 | */ |
| 397 | function getVisitorKeys(node, options) { |
| 398 | const nodeTypeKey = (options && options.nodeTypeKey) || 'type'; |
| 399 | |
| 400 | const nodeType = node[nodeTypeKey]; |
| 401 | if (options && options.visitorKeys && options.visitorKeys[nodeType]) { |
| 402 | return options.visitorKeys[nodeType]; |
| 403 | } |
| 404 | if (estraverse.VisitorKeys[nodeType]) { |
| 405 | return estraverse.VisitorKeys[nodeType]; |
| 406 | } |
| 407 | if (options && typeof options.fallback === 'function') { |
| 408 | return options.fallback(node); |
| 409 | } |
| 410 | // 'iteration' fallback |
| 411 | return Object.keys(node).filter(function (key) { |
| 412 | return key !== nodeTypeKey; |
| 413 | }); |
| 414 | } |
| 415 | |
| 416 | |
| 417 | /** |