rearchitecting wip

This commit is contained in:
MapleLeaf
2021-12-16 19:01:37 -06:00
parent ffc91900d2
commit 460e7cde1a
16 changed files with 224 additions and 289 deletions

View File

@@ -0,0 +1,20 @@
import { inspect } from "node:util"
export function withLoggedMethodCalls<T extends object>(value: T) {
return new Proxy(value as Record<string | symbol, unknown>, {
get(target, property) {
const value = target[property]
if (typeof value !== "function") {
return value
}
return (...values: any[]) => {
console.log(
`${String(property)}(${values
.map((value: any) => inspect(value))
.join(", ")})`,
)
return value.apply(target, values)
}
},
}) as T
}