javascript - 在装饰器中获取原始方法的文件路径?
问题描述
我正在寻找一种方法来获取我的原始函数在它的装饰器中的文件路径,而不通过函数参数传递它,该函数参数位于不同的(一些常见的)目录中,因为这个装饰器用于许多其他功能。任何想法?谢谢!
// decorator in a different folder
export const SomeDecoratorFunction = () => (target, key, descriptor) => {
const originalFunction = descriptor.value;
descriptor.value = function (this) {
// Get file path of originalFunction
return originalFunction.apply(this, arguments);
};
return descriptor;
};
// original function
@SomeDecoratorFunction()
public async someFunction(req: Request, res: Response): Promise<void> {
// some code
}
解决方案
推荐阅读
- python - hashlib "TypeError: 'str' 对象不可调用"
- c# - Asp.net core webapi entityframework如何查询distinct而不是in
- c# - 使用扩展方法将新类型注册到存储系统
- processing - 碰撞,当物体撞击另一个物体时如何使用碰撞
- android - 如何检查 APK/AAB 二进制文件是否在调试模式下签名?
- python - 如何在 Python 中将 SVG 图像渲染为 PNG 文件?
- tensorflow - 使用 tf.data.Dataset.from_tensor_slices 为 BERT 模型输入一些数据
- python - 如何使用python识别短词的扩展文本,例如:“mgmt”用于管理,“svcs”用于使用python的服务
- java - 在颤振中的 MainActivity.java 中找不到嵌入
- google-chrome - 如何知道 getDisplayMedia() 共享了哪个屏幕