MCPcopy Create free account
hub / github.com/DavidWells/analytics / getExports

Function getExports

scripts/docs/parse/index.js:138–175  ·  view source on GitHub ↗
(body)

Source from the content-addressed store, hash-verified

136// }
137
138function getExports(body) {
139 return body.filter((node) => {
140 return (node.type === 'ExpressionStatement' ||
141 node.type === 'ExportDefaultDeclaration' || node.type === 'ExportNamedDeclaration')
142 }).map((node) => {
143 // ES6 default export
144 if (node.type === 'ExportDefaultDeclaration') {
145 // console.log('node', node)
146 const { declaration } = node
147 const name = declaration.name || declaration.id.name
148 return {
149 isDefault: true,
150 name: name,
151 statement: `export default ${name}`
152 }
153 }
154 // ES6 named export
155 if (node.type === 'ExportNamedDeclaration') {
156 const { declaration } = node
157 return {
158 isDefault: false,
159 name: getName(declaration),
160 statement: 'todo'
161 }
162 }
163
164 const { left, right } = node.expression
165 const leftValue = resolveLeft(left)
166 const rightValue = resolveRight(right)
167 // Check if main export
168 const isDefault = leftValue === 'module.exports'
169 return {
170 isDefault: isDefault,
171 name: rightValue,
172 statement: `${leftValue} = ${rightValue}`
173 }
174 })
175}
176
177function getReturnStatment(body) {
178 return body.filter((node) => {

Callers 1

parseCodeFunction · 0.85

Calls 3

resolveLeftFunction · 0.85
resolveRightFunction · 0.85
getNameFunction · 0.70

Tested by

no test coverage detected