timer.js 770 B

1234567891011121314151617181920212223
  1. /**
  2. * 计时装饰器
  3. */
  4. export function timer(label) {
  5. var debug = localStorage.getItem('__debug__');
  6. return function (target, propertyKey, descriptor) {
  7. var timerLabel = "[".concat(propertyKey, "] ").concat(label);
  8. var func = descriptor.value;
  9. if (typeof func === 'function') {
  10. // eslint-disable-next-line
  11. descriptor.value = function () {
  12. var args = [];
  13. for (var _i = 0; _i < arguments.length; _i++) {
  14. args[_i] = arguments[_i];
  15. }
  16. debug && console.time(timerLabel);
  17. func.apply(this, args);
  18. debug && console.timeEnd(timerLabel);
  19. };
  20. }
  21. };
  22. }
  23. //# sourceMappingURL=timer.js.map