monorepon't

This commit is contained in:
MapleLeaf
2021-12-20 20:18:18 -06:00
parent 628c4b23d7
commit e2ea46a18f
32 changed files with 66 additions and 91 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.info(
`${String(property)}(${values
.map((value) => inspect(value, { depth: 1 }))
.join(", ")})`,
)
return value.apply(target, values)
}
},
}) as T
}