Decorated method returns nothing
Ledzz opened this issue · comments
Artem commented
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
Current behavior
Method decorated with @measure
returns nothing. Haven't tested with other decorators.
Expected behavior
Returned value does not change
Minimal reproduction of the problem with instructions
Netanel Basal commented
The issue is here:
descriptor.value = function(...args) {
const start = performance.now();
originalMethod.apply(this, args);
const end = performance.now();
console.log(`Call to ${propertyKey} took ${(end - start).toFixed(2)} milliseconds.`);
};
It should be:
descriptor.value = function(...args) {
const start = performance.now();
const result = originalMethod.apply(this, args);
const end = performance.now();
console.log(`Call to ${propertyKey} took ${(end - start).toFixed(2)} milliseconds.`);
return result;
};
Do you want to create a PR?
Artem commented
yes, I'll do it today :)