timer.js 887 B

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