MCPcopy Create free account
hub / github.com/estools/esquery / getVisitorKeys

Function getVisitorKeys

esquery.js:397–414  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

395 * @returns {string[]} Visitor keys of the node.
396 */
397function 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/**

Callers 3

siblingFunction · 0.85
adjacentFunction · 0.85
nthChildFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected