mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 02:54:11 +08:00
fix(core): profile decorator (#10476)
This commit is contained in:
@ -177,10 +177,10 @@ export function disable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function profileFunction<F extends Function>(fn: F, customName?: string): F {
|
function profileFunction<F extends Function>(fn: F, customName?: string): F {
|
||||||
return profileFunctionFactory(fn, customName || fn.name);
|
return profileFunctionFactory<F>(fn, customName || fn.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const profileMethodUnnamed = (target, key, descriptor) => {
|
const profileMethodUnnamed = (target: Object, key: symbol | string, descriptor) => {
|
||||||
// save a reference to the original method this way we keep the values currently in the
|
// save a reference to the original method this way we keep the values currently in the
|
||||||
// descriptor and don't overwrite what another decorator might have done to the descriptor.
|
// descriptor and don't overwrite what another decorator might have done to the descriptor.
|
||||||
if (descriptor === undefined) {
|
if (descriptor === undefined) {
|
||||||
@ -193,7 +193,7 @@ const profileMethodUnnamed = (target, key, descriptor) => {
|
|||||||
className = target.constructor.name + '.';
|
className = target.constructor.name + '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = className + key;
|
const name = className + key?.toString();
|
||||||
|
|
||||||
//editing the descriptor/value parameter
|
//editing the descriptor/value parameter
|
||||||
descriptor.value = profileFunctionFactory(originalMethod, name, MemberType.Instance);
|
descriptor.value = profileFunctionFactory(originalMethod, name, MemberType.Instance);
|
||||||
@ -202,7 +202,7 @@ const profileMethodUnnamed = (target, key, descriptor) => {
|
|||||||
return descriptor;
|
return descriptor;
|
||||||
};
|
};
|
||||||
|
|
||||||
const profileStaticMethodUnnamed = (ctor, key, descriptor) => {
|
const profileStaticMethodUnnamed = <F extends Function>(ctor: F, key: symbol | string, descriptor) => {
|
||||||
// save a reference to the original method this way we keep the values currently in the
|
// save a reference to the original method this way we keep the values currently in the
|
||||||
// descriptor and don't overwrite what another decorator might have done to the descriptor.
|
// descriptor and don't overwrite what another decorator might have done to the descriptor.
|
||||||
if (descriptor === undefined) {
|
if (descriptor === undefined) {
|
||||||
@ -214,7 +214,7 @@ const profileStaticMethodUnnamed = (ctor, key, descriptor) => {
|
|||||||
if (ctor && ctor.name) {
|
if (ctor && ctor.name) {
|
||||||
className = ctor.name + '.';
|
className = ctor.name + '.';
|
||||||
}
|
}
|
||||||
const name = className + key;
|
const name = className + key?.toString();
|
||||||
|
|
||||||
//editing the descriptor/value parameter
|
//editing the descriptor/value parameter
|
||||||
descriptor.value = profileFunctionFactory(originalMethod, name, MemberType.Static);
|
descriptor.value = profileFunctionFactory(originalMethod, name, MemberType.Static);
|
||||||
|
Reference in New Issue
Block a user