@mkmod-ts/ts-get-exported-function
v1.0.0
Published
Uses `typescript` to get any `export`ed function from a `.ts` file:
Downloads
2
Readme
@mkmod-ts/ts-get-exported-function
Uses typescript
to get any export
ed function from a .ts
file:
const getExportedFunction = require("@mkmod-ts/ts-get-exported-function")
const code = `
export default function(s: string, n: number) {
}
`
console.log(
getExportedFunction(code, "default")
)
Result is in the following format:
{
parameters: [{
name: "name of parameter",
text: "textual representation of parameter",
type: "type of parameter"
}, ...],
returnType: "the return type of the function",
declarationWithFunctionName(name) {
// returns declaration with a user set name like:
return "<name>(<params>):<returnType>"
}
}
or null
if function was not found.