Skip to content
This repository has been archived by the owner on Dec 12, 2020. It is now read-only.

Commit

Permalink
chore: Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ktutnik committed Sep 4, 2020
1 parent ce88ff6 commit 2cceab1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
"license": "MIT",
"dependencies": {
"@types/acorn": "4.0.5",
"acorn": "7.4.0",
"acorn": "8.0.1",
"reflect-metadata": "^0.1.13"
},
"devDependencies": {
"@types/jest": "^26.0.9",
"@types/node": "^14.0.27",
"@types/jest": "^26.0.13",
"@types/node": "^14.6.4",
"coveralls": "^3.1.0",
"jest": "^26.2.2",
"ts-jest": "^26.1.4",
"tslib": "^2.0.0",
"typescript": "^3.9.7"
"jest": "^26.4.2",
"ts-jest": "^26.3.0",
"tslib": "^2.0.1",
"typescript": "^4.0.2"
}
}
14 changes: 7 additions & 7 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,33 +49,33 @@ function getNamesFromAst(nodes: any[]) {
return nodes.map(x => getName(x)).filter((x): x is string | { [key: string]: string[] } => !!x)
}

function getCode(fn:Class|Function){
function getCode(fn: Class | Function) {
const code = fn.toString()
if(code.search(/^class(\s*)extends\s*option.parent\s*{\s*}/gm) > -1) {
if (code.search(/^class(\s*)extends\s*option.parent\s*{\s*}/gm) > -1) {
return "class DynamicClass extends parent {}"
}
else
else
return code.replace("[native code]", "")
}

function getMethodParameters(fn: Class, method: string) {
const body = getCode(fn)
const ast = parse(body)
const ast = parse(body, { ecmaVersion: 2020 })
const ctor = getNode(ast, x => x.type === "MethodDefinition" && x.kind === "method" && x.key.name === method)
return getNamesFromAst(ctor ? (ctor as any).value.params : [])
}

function getConstructorParameters(fn: Class) {
const body = getCode(fn)
const ast = parse(body)
const ast = parse(body, { ecmaVersion: 2020 })
const ctor = getNode(ast, x => x.type === "MethodDefinition" && x.kind === "constructor")
return getNamesFromAst(ctor ? (ctor as any).value.params : [])
}

function getFunctionParameters(fn: Function) {
try {
const body = getCode(fn)
const ast = parse(body)
const ast = parse(body, { ecmaVersion: 2020 })
return getNamesFromAst((ast as any).body[0].params)
}
catch {
Expand Down Expand Up @@ -176,7 +176,7 @@ function parseConstructor(fn: Class): ConstructorReflection {
function parseClass(fn: Class): ClassReflection {
const proto = Object.getPrototypeOf(fn)
return {
kind: "Class", name: fn.name, type: fn, decorators: [],
kind: "Class", name: fn.name, type: fn, decorators: [],
methods: parseMethods(fn),
properties: parseProperties(fn),
ctor: parseConstructor(fn),
Expand Down

0 comments on commit 2cceab1

Please sign in to comment.