15 lines
274 B
TypeScript
Raw Permalink Normal View History

2024-11-05 10:09:18 +08:00
const funcProto = Function.prototype
const funcToString = funcProto.toString
export function toSource(func: any) {
if (func != null) {
try {
return funcToString.call(func)
} catch (e) {}
try {
return `${func}`
} catch (e) {}
}
return ''
}