Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getNameFromPath(path: NodePath): ?string {
var node = path.node;
switch (node.type) {
case types.Identifier.name:
case types.Literal.name:
return getNameOrValue(path);
case types.MemberExpression.name:
return utils
.getMembers(path)
.reduce(
(name, { path, computed }) =>
computed && getNameFromPath(path)
? name
: `${name}.${getNameFromPath(path) || ''}`,
getNameFromPath(path.get('object'))
);
default:
return null;
}
}