Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierZal committed May 19, 2024
1 parent fcf7efa commit 35e5f9e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions decorators/addToLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export default <T extends new (...args: any[]) => SimpleClass>(

#commonLog(logType: 'error' | 'log', ...args: unknown[]): void {
super[logType](
...logs.flatMap((log): [unknown, '-'] => {
...logs.flatMap((log) => {
let arg0: unknown = log
if (log in this) {
return [this[log as keyof this], '-']
}
if (log.endsWith(PARENTHESES)) {
arg0 = this[log as keyof this]
} else if (log.endsWith(PARENTHESES)) {
const funcName = log.slice(FIRST_CHAR, -PARENTHESES.length)
if (
funcName in this &&
Expand All @@ -32,11 +32,11 @@ export default <T extends new (...args: any[]) => SimpleClass>(
...funcArgs: unknown[]
) => unknown
if (!func.length) {
return [func.call(this), '-']
arg0 = func.call(this)
}
}
}
return [log, '-']
return [arg0, '-']
}),
...args,
)
Expand Down

0 comments on commit 35e5f9e

Please sign in to comment.