'use strict'; function shortDescription(astNode) { if (astNode.type === "FunctionDeclaration") { return `function ${shortDescription(astNode.id)}(${renderArguments(astNode.params)}) { ... }`; } else if (astNode.type === "ReturnStatement") { return `return ${shortDescription(astNode.argument)}`; } else if (astNode.type === "CallExpression") { return `${shortDescription(astNode.callee)}(${renderArguments(astNode.arguments)})`; } else if (astNode.type === "MemberExpression") { return `${shortDescription(astNode.object)}.${shortDescription(astNode.property)}`; } else if (astNode.type === "Identifier") { return `${astNode.name}`; } else if (astNode.type === "ArrowFunctionExpression") { return `(${renderArguments(astNode.params)}) => { ... }`; } else if (astNode.type === "Literal") { return astNode.raw; } else { return ""; } } function renderArguments(args) { return args.map(arg => shortDescription(arg)).join(", "); } module.exports = shortDescription;