@bemoje/profiler 2.2.3 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/lib/index.cjs +49 -111
  2. package/lib/index.js +48 -110
  3. package/package.json +4 -2
package/lib/index.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  var util = require('util');
4
4
  var predicate = require('es-toolkit/predicate');
5
5
  var types = require('util/types');
6
- var math = require('es-toolkit/math');
6
+ var esToolkit = require('es-toolkit');
7
7
  var colors = require('ansi-colors');
8
8
  var memoizee = require('memoizee');
9
9
  var enhancedMs = require('enhanced-ms');
@@ -208,9 +208,7 @@ function wrapMaybeAsync(func, spy, options = {}) {
208
208
  }
209
209
  const data = spy.onInvoke(this, args);
210
210
  const retval = func.apply(this, args);
211
- return retval instanceof Promise ? retval.then((retval2) => {
212
- return spy.onReturn(data, retval2);
213
- }) : spy.onReturn(data, retval);
211
+ return retval instanceof Promise ? retval.then((retval2) => spy.onReturn(data, retval2)) : spy.onReturn(data, retval);
214
212
  });
215
213
  }
216
214
  __name(wrapMaybeAsync, "wrapMaybeAsync");
@@ -347,9 +345,7 @@ __name(iterateMethods, "iterateMethods");
347
345
 
348
346
  // src/internal/FunctionProfiler/profilerWrap.ts
349
347
  function profilerWrap(func, profiler) {
350
- const ignore = /* @__PURE__ */ __name(() => {
351
- return !Profiler.enabled;
352
- }, "ignore");
348
+ const ignore = /* @__PURE__ */ __name(() => !Profiler.enabled, "ignore");
353
349
  return profiler.id.type === "get" || profiler.id.type === "set" ? functionSpy(func, profiler, {
354
350
  ignore,
355
351
  async: false
@@ -533,7 +529,7 @@ var NumberFormatter = class {
533
529
  */
534
530
  format(number) {
535
531
  const negative = number >= 0 ? "" : "-";
536
- const split = Math.abs(math.round(number, this.precision)).toString().split(".");
532
+ const split = Math.abs(esToolkit.round(number, this.precision)).toString().split(".");
537
533
  const decimals = this.precision ? this.decimalSeparator + (split[1] || "").padEnd(this.precision, "0") : "";
538
534
  let result = "";
539
535
  for (let i = 0; i < split[0].length; i++) {
@@ -548,9 +544,7 @@ var NumberFormatter = class {
548
544
  * Parse a formatted string to a number.
549
545
  */
550
546
  parse(string) {
551
- string = string.replaceAll(this.thousandSeparator, "").replace(this.decimalSeparator, ".").replaceAll(/[^\d.-]/g, "").split(".").map((s) => {
552
- return parseInt(s);
553
- }).join(".");
547
+ string = string.replaceAll(this.thousandSeparator, "").replace(this.decimalSeparator, ".").replaceAll(/[^\d.-]/g, "").split(".").map((s) => parseInt(s)).join(".");
554
548
  const n = Number(string);
555
549
  return n;
556
550
  }
@@ -711,9 +705,7 @@ function memoizeSync(arg = {}) {
711
705
  } else {
712
706
  const wmap = /* @__PURE__ */ new WeakMap();
713
707
  descriptor.value = function(...args) {
714
- const memoized = mapGetOrDefault(wmap, this, () => {
715
- return memoizee__default.default(orig, options);
716
- });
708
+ const memoized = mapGetOrDefault(wmap, this, () => memoizee__default.default(orig, options));
717
709
  return memoized.apply(this, args);
718
710
  };
719
711
  }
@@ -736,9 +728,7 @@ function createLazyPropDecorator(map) {
736
728
  const { get, value } = descriptor;
737
729
  if (predicate.isFunction(get)) {
738
730
  descriptor.get = function() {
739
- return mapGetOrDefault(map, this, () => {
740
- return get.call(this);
741
- });
731
+ return mapGetOrDefault(map, this, () => get.call(this));
742
732
  };
743
733
  return descriptor;
744
734
  }
@@ -773,9 +763,7 @@ var TableFormatter = class _TableFormatter {
773
763
  color: {
774
764
  separator: colors__default.default.dim.gray,
775
765
  columnHeader: colors__default.default.cyan,
776
- rowHeader: /* @__PURE__ */ __name((s) => {
777
- return s;
778
- }, "rowHeader"),
766
+ rowHeader: /* @__PURE__ */ __name((s) => s, "rowHeader"),
779
767
  string: colors__default.default.green,
780
768
  positiveNumber: colors__default.default.yellow,
781
769
  negativeNumber: colors__default.default.yellow,
@@ -790,38 +778,26 @@ var TableFormatter = class _TableFormatter {
790
778
  this.options = this.handleOptions(options);
791
779
  }
792
780
  get numberColumnPrecisions() {
793
- return this.table.reduce((acc, row) => {
794
- return row.map((cell, c) => {
795
- if (typeof cell !== "number") {
796
- return;
797
- }
798
- if (Number.isInteger(cell)) {
799
- return 0;
800
- }
801
- const digits = cell.toString().split(".")[1].length;
802
- return Math.max(acc[c] || 0, digits);
803
- });
804
- }, []);
781
+ return this.table.reduce((acc, row) => row.map((cell, c) => {
782
+ if (typeof cell !== "number") {
783
+ return;
784
+ }
785
+ if (Number.isInteger(cell)) {
786
+ return 0;
787
+ }
788
+ const digits = cell.toString().split(".")[1].length;
789
+ return Math.max(acc[c] || 0, digits);
790
+ }), []);
805
791
  }
806
792
  get stringsTable() {
807
- return this.table.map((row) => {
808
- return row.map((cell, c) => {
809
- return this.cellToString(cell, c);
810
- });
811
- });
793
+ return this.table.map((row) => row.map((cell, c) => this.cellToString(cell, c)));
812
794
  }
813
795
  get columnWidths() {
814
- return this.stringsTable.reduce((acc, row) => {
815
- return row.map((cell, c) => {
816
- return Math.max(acc[c] || 0, cell.length);
817
- });
818
- }, []);
796
+ return this.stringsTable.reduce((acc, row) => row.map((cell, c) => Math.max(acc[c] || 0, cell.length)), []);
819
797
  }
820
798
  get tableWidth() {
821
799
  const separatorsWidth = (this.columnWidths.length - 1) * this.options.columnSeparator.length;
822
- const columnsWidth = this.columnWidths.reduce((acc, width) => {
823
- return acc + width;
824
- }, 0);
800
+ const columnsWidth = this.columnWidths.reduce((acc, width) => acc + width, 0);
825
801
  return columnsWidth + separatorsWidth;
826
802
  }
827
803
  get columnSeparatorFormatted() {
@@ -831,11 +807,7 @@ var TableFormatter = class _TableFormatter {
831
807
  return this.options.color.separator("".padEnd(this.tableWidth, this.options.headerRowSeparator));
832
808
  }
833
809
  get formattedRows() {
834
- const result = this.stringsTable.map((row, r) => {
835
- return row.map((cell, c) => {
836
- return this.formatCell(cell, c, r);
837
- });
838
- });
810
+ const result = this.stringsTable.map((row, r) => row.map((cell, c) => this.formatCell(cell, c, r)));
839
811
  if (!this.options.color || !this.options.grayOutRow) {
840
812
  return result;
841
813
  }
@@ -843,15 +815,11 @@ var TableFormatter = class _TableFormatter {
843
815
  if (!this.options.grayOutRow(this.table[r])) {
844
816
  return row;
845
817
  }
846
- return row.map((cell) => {
847
- return this.options.color.separator(colors__default.default.stripColor(cell));
848
- });
818
+ return row.map((cell) => this.options.color.separator(colors__default.default.stripColor(cell)));
849
819
  });
850
820
  }
851
821
  get formattedLines() {
852
- const lines = this.formattedRows.map((row) => {
853
- return row.join(this.columnSeparatorFormatted);
854
- });
822
+ const lines = this.formattedRows.map((row) => row.join(this.columnSeparatorFormatted));
855
823
  lines.splice(1, 0, this.headerRowSeparatorLineFormatted);
856
824
  const headersLine = lines[0];
857
825
  lines.push(this.headerRowSeparatorLineFormatted);
@@ -992,30 +960,14 @@ _ts_decorate([
992
960
  _ts_metadata("design:paramtypes", [])
993
961
  ], TableFormatter.prototype, "formattedLines", null);
994
962
  var defaultColorsNoop = {
995
- separator: /* @__PURE__ */ __name((s) => {
996
- return s;
997
- }, "separator"),
998
- columnHeader: /* @__PURE__ */ __name((s) => {
999
- return s;
1000
- }, "columnHeader"),
1001
- rowHeader: /* @__PURE__ */ __name((s) => {
1002
- return s;
1003
- }, "rowHeader"),
1004
- string: /* @__PURE__ */ __name((s) => {
1005
- return s;
1006
- }, "string"),
1007
- positiveNumber: /* @__PURE__ */ __name((s) => {
1008
- return s;
1009
- }, "positiveNumber"),
1010
- negativeNumber: /* @__PURE__ */ __name((s) => {
1011
- return s;
1012
- }, "negativeNumber"),
1013
- booleanTrue: /* @__PURE__ */ __name((s) => {
1014
- return s;
1015
- }, "booleanTrue"),
1016
- booleanFalse: /* @__PURE__ */ __name((s) => {
1017
- return s;
1018
- }, "booleanFalse")
963
+ separator: /* @__PURE__ */ __name((s) => s, "separator"),
964
+ columnHeader: /* @__PURE__ */ __name((s) => s, "columnHeader"),
965
+ rowHeader: /* @__PURE__ */ __name((s) => s, "rowHeader"),
966
+ string: /* @__PURE__ */ __name((s) => s, "string"),
967
+ positiveNumber: /* @__PURE__ */ __name((s) => s, "positiveNumber"),
968
+ negativeNumber: /* @__PURE__ */ __name((s) => s, "negativeNumber"),
969
+ booleanTrue: /* @__PURE__ */ __name((s) => s, "booleanTrue"),
970
+ booleanFalse: /* @__PURE__ */ __name((s) => s, "booleanFalse")
1019
971
  };
1020
972
  var Profiler = class _Profiler {
1021
973
  static {
@@ -1035,9 +987,7 @@ var Profiler = class _Profiler {
1035
987
  _Profiler.classPrototype(target, options?.ignorePrototypeKeys);
1036
988
  return target;
1037
989
  } else {
1038
- return (target) => {
1039
- return _Profiler.class(target, targetOrOptions);
1040
- };
990
+ return (target) => _Profiler.class(target, targetOrOptions);
1041
991
  }
1042
992
  }
1043
993
  static classStatic(target, ignoreKeys) {
@@ -1076,20 +1026,14 @@ ${func.toString()}`);
1076
1026
  return func;
1077
1027
  }
1078
1028
  static getResults(options) {
1079
- const results = _Profiler.data.map((profiler) => {
1080
- return [
1081
- profiler.id.name,
1082
- profiler.getResult()
1083
- ];
1084
- });
1029
+ const results = _Profiler.data.map((profiler) => [
1030
+ profiler.id.name,
1031
+ profiler.getResult()
1032
+ ]);
1085
1033
  const sortkey1 = options?.sortBy ?? "calls";
1086
- const sortValue1 = /* @__PURE__ */ __name((entry) => {
1087
- return entry[1][sortkey1] ?? -1;
1088
- }, "sortValue1");
1034
+ const sortValue1 = /* @__PURE__ */ __name((entry) => entry[1][sortkey1] ?? -1, "sortValue1");
1089
1035
  const sortKey2 = sortkey1 === "calls" ? "totalTimeUs" : "calls";
1090
- const sortValue2 = /* @__PURE__ */ __name((entry) => {
1091
- return entry[1][sortKey2] ?? -1;
1092
- }, "sortValue2");
1036
+ const sortValue2 = /* @__PURE__ */ __name((entry) => entry[1][sortKey2] ?? -1, "sortValue2");
1093
1037
  return results.sort((a, b) => {
1094
1038
  const comparision = sortValue1(a) - sortValue1(b);
1095
1039
  if (comparision !== 0) {
@@ -1111,30 +1055,24 @@ ${func.toString()}`);
1111
1055
  "min",
1112
1056
  "max"
1113
1057
  ];
1114
- const rows = entries.map(([method, stats]) => {
1115
- return [
1116
- method,
1117
- stats.calls,
1118
- stats.totalTimeUs,
1119
- stats.avgTimeUs,
1120
- stats.minTimeUs,
1121
- stats.maxTimeUs
1122
- ];
1123
- });
1058
+ const rows = entries.map(([method, stats]) => [
1059
+ method,
1060
+ stats.calls,
1061
+ stats.totalTimeUs,
1062
+ stats.avgTimeUs,
1063
+ stats.minTimeUs,
1064
+ stats.maxTimeUs
1065
+ ]);
1124
1066
  const table = [
1125
1067
  headers,
1126
1068
  ...rows
1127
1069
  ];
1128
1070
  const formatter = new TableFormatter(table, {
1129
1071
  color: !options?.noColor,
1130
- grayOutRow: /* @__PURE__ */ __name((row) => {
1131
- return row[1] === 0;
1132
- }, "grayOutRow")
1072
+ grayOutRow: /* @__PURE__ */ __name((row) => row[1] === 0, "grayOutRow")
1133
1073
  });
1134
1074
  console.log();
1135
- formatter.formattedLines.forEach((line) => {
1136
- return console.log(line);
1137
- });
1075
+ formatter.formattedLines.forEach((line) => console.log(line));
1138
1076
  console.log();
1139
1077
  }
1140
1078
  static [util.inspect.custom](depth, options = {}) {
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { inspect } from 'util';
2
2
  import { isSymbol, isFunction } from 'es-toolkit/predicate';
3
3
  import { isAsyncFunction } from 'util/types';
4
- import { round } from 'es-toolkit/math';
4
+ import { round } from 'es-toolkit';
5
5
  import colors from 'ansi-colors';
6
6
  import memoizee from 'memoizee';
7
7
  import { ms } from 'enhanced-ms';
@@ -201,9 +201,7 @@ function wrapMaybeAsync(func, spy, options = {}) {
201
201
  }
202
202
  const data = spy.onInvoke(this, args);
203
203
  const retval = func.apply(this, args);
204
- return retval instanceof Promise ? retval.then((retval2) => {
205
- return spy.onReturn(data, retval2);
206
- }) : spy.onReturn(data, retval);
204
+ return retval instanceof Promise ? retval.then((retval2) => spy.onReturn(data, retval2)) : spy.onReturn(data, retval);
207
205
  });
208
206
  }
209
207
  __name(wrapMaybeAsync, "wrapMaybeAsync");
@@ -340,9 +338,7 @@ __name(iterateMethods, "iterateMethods");
340
338
 
341
339
  // src/internal/FunctionProfiler/profilerWrap.ts
342
340
  function profilerWrap(func, profiler) {
343
- const ignore = /* @__PURE__ */ __name(() => {
344
- return !Profiler.enabled;
345
- }, "ignore");
341
+ const ignore = /* @__PURE__ */ __name(() => !Profiler.enabled, "ignore");
346
342
  return profiler.id.type === "get" || profiler.id.type === "set" ? functionSpy(func, profiler, {
347
343
  ignore,
348
344
  async: false
@@ -541,9 +537,7 @@ var NumberFormatter = class {
541
537
  * Parse a formatted string to a number.
542
538
  */
543
539
  parse(string) {
544
- string = string.replaceAll(this.thousandSeparator, "").replace(this.decimalSeparator, ".").replaceAll(/[^\d.-]/g, "").split(".").map((s) => {
545
- return parseInt(s);
546
- }).join(".");
540
+ string = string.replaceAll(this.thousandSeparator, "").replace(this.decimalSeparator, ".").replaceAll(/[^\d.-]/g, "").split(".").map((s) => parseInt(s)).join(".");
547
541
  const n = Number(string);
548
542
  return n;
549
543
  }
@@ -704,9 +698,7 @@ function memoizeSync(arg = {}) {
704
698
  } else {
705
699
  const wmap = /* @__PURE__ */ new WeakMap();
706
700
  descriptor.value = function(...args) {
707
- const memoized = mapGetOrDefault(wmap, this, () => {
708
- return memoizee(orig, options);
709
- });
701
+ const memoized = mapGetOrDefault(wmap, this, () => memoizee(orig, options));
710
702
  return memoized.apply(this, args);
711
703
  };
712
704
  }
@@ -729,9 +721,7 @@ function createLazyPropDecorator(map) {
729
721
  const { get, value } = descriptor;
730
722
  if (isFunction(get)) {
731
723
  descriptor.get = function() {
732
- return mapGetOrDefault(map, this, () => {
733
- return get.call(this);
734
- });
724
+ return mapGetOrDefault(map, this, () => get.call(this));
735
725
  };
736
726
  return descriptor;
737
727
  }
@@ -766,9 +756,7 @@ var TableFormatter = class _TableFormatter {
766
756
  color: {
767
757
  separator: colors.dim.gray,
768
758
  columnHeader: colors.cyan,
769
- rowHeader: /* @__PURE__ */ __name((s) => {
770
- return s;
771
- }, "rowHeader"),
759
+ rowHeader: /* @__PURE__ */ __name((s) => s, "rowHeader"),
772
760
  string: colors.green,
773
761
  positiveNumber: colors.yellow,
774
762
  negativeNumber: colors.yellow,
@@ -783,38 +771,26 @@ var TableFormatter = class _TableFormatter {
783
771
  this.options = this.handleOptions(options);
784
772
  }
785
773
  get numberColumnPrecisions() {
786
- return this.table.reduce((acc, row) => {
787
- return row.map((cell, c) => {
788
- if (typeof cell !== "number") {
789
- return;
790
- }
791
- if (Number.isInteger(cell)) {
792
- return 0;
793
- }
794
- const digits = cell.toString().split(".")[1].length;
795
- return Math.max(acc[c] || 0, digits);
796
- });
797
- }, []);
774
+ return this.table.reduce((acc, row) => row.map((cell, c) => {
775
+ if (typeof cell !== "number") {
776
+ return;
777
+ }
778
+ if (Number.isInteger(cell)) {
779
+ return 0;
780
+ }
781
+ const digits = cell.toString().split(".")[1].length;
782
+ return Math.max(acc[c] || 0, digits);
783
+ }), []);
798
784
  }
799
785
  get stringsTable() {
800
- return this.table.map((row) => {
801
- return row.map((cell, c) => {
802
- return this.cellToString(cell, c);
803
- });
804
- });
786
+ return this.table.map((row) => row.map((cell, c) => this.cellToString(cell, c)));
805
787
  }
806
788
  get columnWidths() {
807
- return this.stringsTable.reduce((acc, row) => {
808
- return row.map((cell, c) => {
809
- return Math.max(acc[c] || 0, cell.length);
810
- });
811
- }, []);
789
+ return this.stringsTable.reduce((acc, row) => row.map((cell, c) => Math.max(acc[c] || 0, cell.length)), []);
812
790
  }
813
791
  get tableWidth() {
814
792
  const separatorsWidth = (this.columnWidths.length - 1) * this.options.columnSeparator.length;
815
- const columnsWidth = this.columnWidths.reduce((acc, width) => {
816
- return acc + width;
817
- }, 0);
793
+ const columnsWidth = this.columnWidths.reduce((acc, width) => acc + width, 0);
818
794
  return columnsWidth + separatorsWidth;
819
795
  }
820
796
  get columnSeparatorFormatted() {
@@ -824,11 +800,7 @@ var TableFormatter = class _TableFormatter {
824
800
  return this.options.color.separator("".padEnd(this.tableWidth, this.options.headerRowSeparator));
825
801
  }
826
802
  get formattedRows() {
827
- const result = this.stringsTable.map((row, r) => {
828
- return row.map((cell, c) => {
829
- return this.formatCell(cell, c, r);
830
- });
831
- });
803
+ const result = this.stringsTable.map((row, r) => row.map((cell, c) => this.formatCell(cell, c, r)));
832
804
  if (!this.options.color || !this.options.grayOutRow) {
833
805
  return result;
834
806
  }
@@ -836,15 +808,11 @@ var TableFormatter = class _TableFormatter {
836
808
  if (!this.options.grayOutRow(this.table[r])) {
837
809
  return row;
838
810
  }
839
- return row.map((cell) => {
840
- return this.options.color.separator(colors.stripColor(cell));
841
- });
811
+ return row.map((cell) => this.options.color.separator(colors.stripColor(cell)));
842
812
  });
843
813
  }
844
814
  get formattedLines() {
845
- const lines = this.formattedRows.map((row) => {
846
- return row.join(this.columnSeparatorFormatted);
847
- });
815
+ const lines = this.formattedRows.map((row) => row.join(this.columnSeparatorFormatted));
848
816
  lines.splice(1, 0, this.headerRowSeparatorLineFormatted);
849
817
  const headersLine = lines[0];
850
818
  lines.push(this.headerRowSeparatorLineFormatted);
@@ -985,30 +953,14 @@ _ts_decorate([
985
953
  _ts_metadata("design:paramtypes", [])
986
954
  ], TableFormatter.prototype, "formattedLines", null);
987
955
  var defaultColorsNoop = {
988
- separator: /* @__PURE__ */ __name((s) => {
989
- return s;
990
- }, "separator"),
991
- columnHeader: /* @__PURE__ */ __name((s) => {
992
- return s;
993
- }, "columnHeader"),
994
- rowHeader: /* @__PURE__ */ __name((s) => {
995
- return s;
996
- }, "rowHeader"),
997
- string: /* @__PURE__ */ __name((s) => {
998
- return s;
999
- }, "string"),
1000
- positiveNumber: /* @__PURE__ */ __name((s) => {
1001
- return s;
1002
- }, "positiveNumber"),
1003
- negativeNumber: /* @__PURE__ */ __name((s) => {
1004
- return s;
1005
- }, "negativeNumber"),
1006
- booleanTrue: /* @__PURE__ */ __name((s) => {
1007
- return s;
1008
- }, "booleanTrue"),
1009
- booleanFalse: /* @__PURE__ */ __name((s) => {
1010
- return s;
1011
- }, "booleanFalse")
956
+ separator: /* @__PURE__ */ __name((s) => s, "separator"),
957
+ columnHeader: /* @__PURE__ */ __name((s) => s, "columnHeader"),
958
+ rowHeader: /* @__PURE__ */ __name((s) => s, "rowHeader"),
959
+ string: /* @__PURE__ */ __name((s) => s, "string"),
960
+ positiveNumber: /* @__PURE__ */ __name((s) => s, "positiveNumber"),
961
+ negativeNumber: /* @__PURE__ */ __name((s) => s, "negativeNumber"),
962
+ booleanTrue: /* @__PURE__ */ __name((s) => s, "booleanTrue"),
963
+ booleanFalse: /* @__PURE__ */ __name((s) => s, "booleanFalse")
1012
964
  };
1013
965
  var Profiler = class _Profiler {
1014
966
  static {
@@ -1028,9 +980,7 @@ var Profiler = class _Profiler {
1028
980
  _Profiler.classPrototype(target, options?.ignorePrototypeKeys);
1029
981
  return target;
1030
982
  } else {
1031
- return (target) => {
1032
- return _Profiler.class(target, targetOrOptions);
1033
- };
983
+ return (target) => _Profiler.class(target, targetOrOptions);
1034
984
  }
1035
985
  }
1036
986
  static classStatic(target, ignoreKeys) {
@@ -1069,20 +1019,14 @@ ${func.toString()}`);
1069
1019
  return func;
1070
1020
  }
1071
1021
  static getResults(options) {
1072
- const results = _Profiler.data.map((profiler) => {
1073
- return [
1074
- profiler.id.name,
1075
- profiler.getResult()
1076
- ];
1077
- });
1022
+ const results = _Profiler.data.map((profiler) => [
1023
+ profiler.id.name,
1024
+ profiler.getResult()
1025
+ ]);
1078
1026
  const sortkey1 = options?.sortBy ?? "calls";
1079
- const sortValue1 = /* @__PURE__ */ __name((entry) => {
1080
- return entry[1][sortkey1] ?? -1;
1081
- }, "sortValue1");
1027
+ const sortValue1 = /* @__PURE__ */ __name((entry) => entry[1][sortkey1] ?? -1, "sortValue1");
1082
1028
  const sortKey2 = sortkey1 === "calls" ? "totalTimeUs" : "calls";
1083
- const sortValue2 = /* @__PURE__ */ __name((entry) => {
1084
- return entry[1][sortKey2] ?? -1;
1085
- }, "sortValue2");
1029
+ const sortValue2 = /* @__PURE__ */ __name((entry) => entry[1][sortKey2] ?? -1, "sortValue2");
1086
1030
  return results.sort((a, b) => {
1087
1031
  const comparision = sortValue1(a) - sortValue1(b);
1088
1032
  if (comparision !== 0) {
@@ -1104,30 +1048,24 @@ ${func.toString()}`);
1104
1048
  "min",
1105
1049
  "max"
1106
1050
  ];
1107
- const rows = entries.map(([method, stats]) => {
1108
- return [
1109
- method,
1110
- stats.calls,
1111
- stats.totalTimeUs,
1112
- stats.avgTimeUs,
1113
- stats.minTimeUs,
1114
- stats.maxTimeUs
1115
- ];
1116
- });
1051
+ const rows = entries.map(([method, stats]) => [
1052
+ method,
1053
+ stats.calls,
1054
+ stats.totalTimeUs,
1055
+ stats.avgTimeUs,
1056
+ stats.minTimeUs,
1057
+ stats.maxTimeUs
1058
+ ]);
1117
1059
  const table = [
1118
1060
  headers,
1119
1061
  ...rows
1120
1062
  ];
1121
1063
  const formatter = new TableFormatter(table, {
1122
1064
  color: !options?.noColor,
1123
- grayOutRow: /* @__PURE__ */ __name((row) => {
1124
- return row[1] === 0;
1125
- }, "grayOutRow")
1065
+ grayOutRow: /* @__PURE__ */ __name((row) => row[1] === 0, "grayOutRow")
1126
1066
  });
1127
1067
  console.log();
1128
- formatter.formattedLines.forEach((line) => {
1129
- return console.log(line);
1130
- });
1068
+ formatter.formattedLines.forEach((line) => console.log(line));
1131
1069
  console.log();
1132
1070
  }
1133
1071
  static [inspect.custom](depth, options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemoje/profiler",
3
- "version": "2.2.3",
3
+ "version": "3.0.1",
4
4
  "description": "Performance profiling utilities for measuring execution time of functions, class methods, and modules.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -9,7 +9,9 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "ansi-colors": "^4.1.3",
12
- "es-toolkit": "^1.45.1"
12
+ "es-toolkit": "^1.45.1",
13
+ "enhanced-ms": "^4.2.0",
14
+ "memoizee": "^0.4.17"
13
15
  },
14
16
  "keywords": [
15
17
  "profiler",