You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
617 B
JavaScript

'use strict';
module.exports = function findNestedProperties(node) {
return Object.keys(node).filter((property) => {
/* We want to ignore any _-prefixed properties; we assume these to be internal, non-AST data. */
return (property[0] !== "_");
}).map((property) => {
let value = node[property];
if (Array.isArray(value) && value.length > 0) {
return {
property: property,
type: "array"
};
} else if (value != null && value.type != null) {
return {
property: property,
type: "node"
};
} else {
return null;
}
}).filter((result) => {
return (result != null);
});
};